timetable 入力の定義
timetable 入力をコマンド ラインで定義できます。前提条件 (assert ステートメント) を使用した timetable 入力の型のプログラムによる指定はサポートされません。
コマンド ラインでの timetable 入力の定義
コマンド ラインで timetable 入力を定義するには、入力の例を提供するか timetable coder 型を使用します。定数の timetable 入力を指定することもできます。
timetable 入力の例の提供
-args オプションを使用します。
TT = timetable(A,B,C,'RowTimes',D,'VariableNames',vnames); fiaccel myFunction -args {TT}
timetable の型の指定
fiaccel への timetable の型を指定するには、次のようにします。
timetable を定義します。以下に例を示します。
TT = timetable(A,B,C,'RowTimes',D,'VariableNames',vnames);
Tから型を作成します。t = coder.typeof(TT);
-argsオプションを使用して、型をfiaccelに渡します。fiaccel myFunction -args {t}
定数 timetable 入力の指定
timetable 入力が定数であることを指定するには、-args オプションと coder.Constant を併用します。
TT = timetable(A,B,C,'RowTimes',D,'VariableNames',vnames); fiaccel myFunction -args {coder.Constant(TT)}
timetable の表現
coder 型オブジェクトは、内部状態の値を除外して、オブジェクトのプロパティの簡潔な説明を表示します。コマンド ライン インターフェイスで表示されるのは、非定数プロパティの型とサイズ、定数プロパティの値です。たとえば、5 行 2 列のサイズの coder timetable 型を作成します。
tt = timetable((1:5)',(11:15)','SampleRate',1);
ttType = coder.typeof(tt)変数 tt の表現が coder 型オブジェクト ttType に格納されます。
ttType =
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.DurationTypeSampleRate または TimeStep を指定して規則的な timetable を定義します。RowTimes を指定して不規則な timetable を定義することもできます。以下に例を示します。
tti = timetable((1:3)','RowTimes',seconds(1:3));
ttiType = coder.typeof(tti)不規則な table tti の表現が coder 型オブジェクト ttiType に格納されます。
ttiType =
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.DurationTypetimetable coder 型の従来の coder.ClassType 表現が必要な場合は、メソッド getCoderType を使用して取得できます。たとえば、ttType オブジェクトの基になる coder.ClassType 表現を確認するには、次のコマンドを使用します。
ttType.getCoderType
ans =
coder.ClassType
1×1 timetable
Properties :
data : 1×2 homogeneous cell
base: 5×1 double
metaDim : 1×1 matlab.internal.coder.tabular.private.metaDim
Properties :
labels : {'Time'} {'Variables'}
length : 1×1 double
rowDim : 1×1 matlab.internal.coder.tabular.private.implicitRegularRowTimesDim
Properties :
length : 5
specifiedAsRate : 1×1 logical
startTime : 1×1 duration
Properties :
millis : 1×1 double
fmt : 1×1 char
sampleRate : 1×1 double
timeStep : 1×1 duration
Properties :
millis : 1×1 double
fmt : 1×1 char
varDim : 1×1 matlab.internal.coder.tabular.private.varNamesDim
Properties :
descrs : 1×2 homogeneous cell
base: 1×0 char
units : 1×2 homogeneous cell
base: 1×0 char
continuity : 1×2 matlab.internal.coder.tabular.Continuity
customProps : 1×1 struct with no fields
hasDescrs : 1×1 logical
hasUnits : 1×1 logical
hasContinuity : 1×1 logical
hasCustomProps : 1×1 logical
labels : {'Var1'} {'Var2'}
length : 1×1 double
arrayProps : 1×1 struct
Description: 1×0 char
UserData: 0×0 doubleオブジェクトのプロパティ
coder timetable 型オブジェクトのプロパティを編集できます。オブジェクトのプロパティにスカラー値を割り当てることができます。coder 型オブジェクトのプロパティに値を割り当てると、対応する coder 型の値に暗黙的に変換されます。オブジェクト自体のサイズを変更するには、coder.resize 関数を使用するか、オブジェクトのプロパティを直接編集します。
coder.resize を使用したオブジェクトのプロパティのサイズ変更
coder.resize を使用して、timetable オブジェクトのサイズとオブジェクトのプロパティのサイズを変更できます。プロパティ内で配列を作成することもできます。
たとえば、5 行 2 列のサイズの coder timetable 型を作成します。Description プロパティのサイズは 1 行 0 列です。
tt = timetable((1:5)',(11:15)','SampleRate',1);
ttType = coder.typeof(tt)
ttType =
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.DurationTypecoder.resize を使用して、UserData を上限が 10 の可変サイズの列ベクトルにします。
ttType.UserData = coder.resize(ttType.UserData,[10 1],[true false])
ttType =
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オブジェクト サイズの直接変更
特定のタイプのオブジェクトについては、オブジェクトのプロパティを編集することでオブジェクト自体のサイズを変更することもできます。たとえば、tType オブジェクトの行数を変更するには、Size プロパティを編集します。
ttType.Size = [10 2]
ttType =
matlab.coder.type.RegularTimetableType
10x2 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
VarDims プロパティを使用して行数を可変サイズにすることもできます。
ttType.VarDims = [true false]
ttType =
matlab.coder.type.RegularTimetableType
:10x2 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参考
timetable | coder.Constant | coder.newtype | coder.typeof