table 入力の定義
コマンド ラインまたは MATLAB® Coder™ アプリで table 入力を定義できます。コード生成では、関数の引数の検証 (arguments
ブロック) または前提条件 (assert
ステートメント) を使用した table
入力型のプログラムによる指定はサポートされていません。
コマンド ラインでの table 入力の定義
次のいずれかの手順を使用します。
または、サンプル入力を使用してエントリポイント関数を呼び出すテスト ファイルがある場合は、coder.getArgTypes
を使用して入力の型を指定できます。
table 入力の例の提供
-args
オプションを使用します。
T = table(A,B,C,'VariableNames',vnames); codegen myFunction -args {T}
table の型の指定
codegen
への table の型を指定するには、次のようにします。
table を定義します。以下に例を示します。
T = table(A,B,C,'VariableNames',vnames);
T
から型を作成します。t = coder.typeof(T);
-args
オプションを使用して、型をcodegen
に渡します。codegen myFunction -args {t}
定数 table 入力の指定
table 入力が定数であることを指定するには、-args
オプションと coder.Constant
を併用します。
T = table(A,B,C,'VariableNames',vnames); codegen myFunction -args {coder.Constant(T)}
MATLAB Coder アプリでの table 入力の定義
次のいずれかの手順を使用します。
table の表現
table の coder 型オブジェクトは、オブジェクトとそのプロパティを記述します。coder.typeof
を使用するか、table
を string スカラーとして coder.newtype
に渡します。
coder 型オブジェクトは、内部状態の値を除外して、オブジェクトのプロパティの簡潔な説明を表示します。非定数プロパティについては型とサイズが表示され、定数プロパティについてはその値だけが表示されます。次に例を示します。
A = [1 2 3]'; B = [4 5 6]'; C = [7 8 9]'; t = table(A,B,C); tType = coder.typeof(t)
変数 t
の表現が coder 型オブジェクト tType
に格納されます。
tType = matlab.coder.type.TableType 3x3 table Data : 1x3 homogeneous cell Description : 1x0 char UserData : 0x0 double DimensionNames : {'Row'} {'Variables'} VariableNames : {'A'} {'B'} {'C'} VariableDescriptions : 1x3 homogeneous cell VariableUnits : 1x3 homogeneous cell VariableContinuity : 1x3 matlab.internal.coder.tabular.Continuity RowNames : 0x0 homogeneous cell
ワークフローで coder 型オブジェクトの従来の表現が必要な場合は、クラスまたはオブジェクトの新しい表現をもつ変数で関数 getCoderType
を使用します。coder 型オブジェクトの従来の表現を参照してください。
coder.resize
を使用したオブジェクトのプロパティのサイズ変更
ほとんどのオブジェクトは、coder.resize
を使用してサイズ変更できます。オブジェクトやそのプロパティのサイズを変更したり、プロパティ内で配列を作成したりできます。
table
coder オブジェクトについて、オブジェクトのプロパティのサイズを次のように変更できます。
A = [1 2 3]'; B = [4 5 6]'; C = [7 8 9]'; t = table(A,B,C); tType = coder.typeof(t) tType.Description = coder.resize(tType.Description,[1 12],[0 1])
このコードは、Description
プロパティのサイズを上限が 12
である 1x:12
の char
プロパティに変更します。
tType = matlab.coder.type.TableType 3x3 table Data : 1x3 homogeneous cell Description : 1x:12 char UserData : 0x0 double DimensionNames : {'Row'} {'Variables'} VariableNames : {'A'} {'B'} {'C'} VariableDescriptions : 1x3 homogeneous cell VariableUnits : 1x3 homogeneous cell VariableContinuity : 1x3 matlab.internal.coder.tabular.Continuity RowNames : 0x0 homogeneous cell
coder.resize
を使用してオブジェクトのサイズを変更することもできます。coder 型オブジェクトとプロパティの編集および表現を参照してください。
参考
table
| coder.Constant
| coder.typeof