copy
操作点または操作点仕様のコピー
構文
op_point2 = copy(op_point1)
op_spec2 = copy(op_spec1)
説明
op_point2 = copy(op_point1)
は op_point1
操作点オブジェクトのコピーを返します。関数 operpoint
を使用して、op_point1
を作成できます。
op_spec2 = copy(op_spec1)
は op_spec1
操作点仕様オブジェクトのコピーを返します。関数 operspec
を使用して、op_spec1
を作成できます。
メモ
op_point2
=op_point1
コマンドは、op_point1
のコピーを作成するのではなく、op_point1
のポインターを作成します。この場合、op_point2
に加えた変更が op_point1
にも反映されます。操作点の仕様についても同様です。例については、操作点の仕様のコピーを参照してください。
例
操作点の仕様のコピー
新しい operspec
変数は次の 3 つの方法で作成することができます。
operspec
コマンドを使用する等号 (
=
) 演算子による割り当てを使用するcopy
コマンドを使用する
=
演算子を使用すると変数がリンク付けられ、どちらの変数も基となる同じデータを指しています。copy
コマンドを使用すると、独立した operspec
オブジェクトになります。この例では operspec
オブジェクトを両方の方法で作成し、それらの動作を検証します。
mdl = 'watertank';
open_system(mdl)
opspec1 = operspec(mdl)
opspec1 = Operating point specification for the Model watertank. (Time-Varying Components Evaluated at time t=0) States: ---------- x Known SteadyState Min Max dxMin dxMax ___________ ___________ ___________ ___________ ___________ ___________ ___________ (1.) watertank/PID Controller/Integrator/Continuous/Integrator 0 false true -Inf Inf -Inf Inf (2.) watertank/Water-Tank System/H 1 false true 0 Inf -Inf Inf Inputs: None ---------- Outputs: None ----------
=
演算子による割り当てを使用して、新しい操作点の仕様オブジェクトを作成します。
opspec2 = opspec1;
opspec2
は、opspec1
と同じ基となるデータを指す operspec
オブジェクトです。このリンクのために、2 つの operspec
オブジェクトのプロパティを独立して変更することはできません。これを確認するには、opspec2
のプロパティを変更します。たとえば、最初の状態の初期値を 0 から 2 に変更します。変更が画面の States
セクションに表示されます。
opspec2.States(1).x = 2
opspec2 = Operating point specification for the Model watertank. (Time-Varying Components Evaluated at time t=0) States: ---------- x Known SteadyState Min Max dxMin dxMax ___________ ___________ ___________ ___________ ___________ ___________ ___________ (1.) watertank/PID Controller/Integrator/Continuous/Integrator 2 false true -Inf Inf -Inf Inf (2.) watertank/Water-Tank System/H 1 false true 0 Inf -Inf Inf Inputs: None ---------- Outputs: None ----------
opspec1
の表示を検証し、opspec1
の対応するプロパティ値も 0 から 2 に変更されることを確認します。
opspec1
opspec1 = Operating point specification for the Model watertank. (Time-Varying Components Evaluated at time t=0) States: ---------- x Known SteadyState Min Max dxMin dxMax ___________ ___________ ___________ ___________ ___________ ___________ ___________ (1.) watertank/PID Controller/Integrator/Continuous/Integrator 2 false true -Inf Inf -Inf Inf (2.) watertank/Water-Tank System/H 1 false true 0 Inf -Inf Inf Inputs: None ---------- Outputs: None ----------
操作点の仕様の独立したコピーを作成するには、copy
コマンドを使用します。
opspec3 = copy(opspec1);
ここで、opspec3
のプロパティを変更しても、opspec1
は変更されません。たとえば、最初の状態の初期値を 2 から 4 に変更します。
opspec3.States(1).x = 4
opspec3 = Operating point specification for the Model watertank. (Time-Varying Components Evaluated at time t=0) States: ---------- x Known SteadyState Min Max dxMin dxMax ___________ ___________ ___________ ___________ ___________ ___________ ___________ (1.) watertank/PID Controller/Integrator/Continuous/Integrator 4 false true -Inf Inf -Inf Inf (2.) watertank/Water-Tank System/H 1 false true 0 Inf -Inf Inf Inputs: None ---------- Outputs: None ----------
opspec1
では、対応する値は 2 のままです。
opspec1.States(1).x
ans = 2
このコピー動作が発生するのは、operspec
が "ハンドル オブジェクト" であるためです。ハンドル オブジェクトの詳細については、ハンドル オブジェクトの動作を参照してください。
操作点のコピー
新しい operating-point 変数は次の 3 つの方法で作成することができます。
関数
operpoint
を使用する等号 (
=
) 演算子による割り当てを使用する関数
copy
を使用する
=
演算子を使用すると変数がリンク付けられ、どちらの変数も基となる同じデータを指しています。関数 copy
を使用すると、結果として独立した操作点オブジェクトが作成されます。この例では操作点オブジェクトを両方の方法で作成し、それらの動作を検証します。
mdl = 'watertank';
open_system(mdl)
op1 = operpoint(mdl)
op1 = Operating point for the Model watertank. (Time-Varying Components Evaluated at time t=0) States: ---------- x _ (1.) watertank/PID Controller/Integrator/Continuous/Integrator 0 (2.) watertank/Water-Tank System/H 1 Inputs: None ----------
=
演算子による割り当てを使用して、新しい操作点オブジェクトを作成します。
op2 = op1;
op2
は、op1
と同じ基となるデータを指す操作点オブジェクトです。このリンクのために、2 つの操作点オブジェクトのプロパティを独立して変更することはできません。これを確認するには、op2
のプロパティを変更します。たとえば、最初の状態の値を 0 から 2 に変更します。変更が画面の States
セクションに表示されます。
op2.States(1).x = 2
op2 = Operating point for the Model watertank. (Time-Varying Components Evaluated at time t=0) States: ---------- x _ (1.) watertank/PID Controller/Integrator/Continuous/Integrator 2 (2.) watertank/Water-Tank System/H 1 Inputs: None ----------
op1
の表示を検証し、op1
の対応するプロパティ値も 0 から 2 に変更されることを確認します。
op1
op1 = Operating point for the Model watertank. (Time-Varying Components Evaluated at time t=0) States: ---------- x _ (1.) watertank/PID Controller/Integrator/Continuous/Integrator 2 (2.) watertank/Water-Tank System/H 1 Inputs: None ----------
操作点オブジェクトの独立したコピーを作成するには、copy
コマンドを使用します。
op3 = copy(op1);
ここで、op3
のプロパティを変更しても、op1
は変更されません。たとえば、最初の状態の値を 2 から 4 に変更します。
op3.States(1).x = 4
op3 = Operating point for the Model watertank. (Time-Varying Components Evaluated at time t=0) States: ---------- x _ (1.) watertank/PID Controller/Integrator/Continuous/Integrator 4 (2.) watertank/Water-Tank System/H 1 Inputs: None ----------
op1
では、対応する値は 2 のままです。
op1.States(1).x
ans = 2
このコピー動作が発生するのは、操作点オブジェクトが "ハンドル オブジェクト" であるためです。ハンドル オブジェクトの詳細については、ハンドル オブジェクトの動作を参照してください。
バージョン履歴
R2006a より前に導入
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)