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