Main Content

table 入力の定義

table 入力をコマンド ラインで定義できます。前提条件 (assert ステートメント) を使用した table 入力の型のプログラムによる指定はサポートされません。

コマンド ラインでの table 入力の定義

次のいずれかの手順を使用します。

または、サンプル入力を使用してエントリポイント関数を呼び出すテスト ファイルがある場合は、coder.getArgTypes を使用して入力の型を指定できます。

table 入力の例の提供

-args オプションを使用します。

T = table(A,B,C,'VariableNames',vnames);
fiaccel myFunction -args {T}

table の型の指定

fiaccel への table の型を指定するには、次のようにします。

  1. table を定義します。以下に例を示します。

    T = table(A,B,C,'VariableNames',vnames);

  2. T から型を作成します。

    t = coder.typeof(T);
    

  3. -args オプションを使用して、型を fiaccel に渡します。

    fiaccel myFunction -args {t}
    

定数 table 入力の指定

table 入力が定数であることを指定するには、-args オプションと coder.Constant を併用します。

T = table(A,B,C,'VariableNames',vnames);
fiaccel myFunction -args {coder.Constant(T)}

table の表現

table の coder 型オブジェクトは、オブジェクトとそのプロパティを記述します。coder.typeof (MATLAB Coder) を使用するか、table を string スカラーとして coder.newtype (MATLAB Coder) に渡します。

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 型オブジェクトの従来の表現 (MATLAB Coder)を参照してください。

coder.resize を使用したオブジェクトのプロパティのサイズ変更

ほとんどのオブジェクトは、coder.resize (MATLAB Coder) を使用してサイズ変更できます。オブジェクトやそのプロパティのサイズを変更したり、プロパティ内で配列を作成したりできます。

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:12char プロパティに変更します。

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 型オブジェクトとプロパティの編集および表現 (MATLAB Coder)を参照してください。

参考

| (MATLAB Coder) | (MATLAB Coder)

関連するトピック