categorical 配列入力の定義
categorical 配列入力をコマンド ラインで定義できます。前提条件 (assert ステートメント) を使用した categorical 入力の型のプログラムによる指定はサポートされません。
コマンド ラインでの categorical 配列入力の指定
コマンド ラインで categorical 配列入力を定義するには、入力の例を提供するか categorical coder 型を使用します。定数の categorical 配列入力を指定することもできます。
categorical 配列入力の例の提供
-args オプションを使用します。
C = categorical({'r','g','b'});
fiaccel myFunction -args {C}
categorical 配列の型の提供
fiaccel に categorical 配列の型を提供するには次のようにします。
categorical 配列を定義します。以下に例を示します。
C = categorical({'r','g','b'});Cから型を作成します。t = coder.typeof(C);
-argsオプションを使用して、型をfiaccelに渡します。fiaccel myFunction -args {t}
定数 categorical 配列入力の提供
categorical 配列入力が定数であることを指定するには、-args オプションを指定して coder.Constant を使用します。
C = categorical({'r','g','b'});
fiaccel myFunction -args {coder.Constant(C)}
categorical 配列の表現
coder 型オブジェクトは、内部状態の値を除外して、オブジェクトのプロパティの簡潔な説明を表示します。コマンド ライン インターフェイスで表示されるのは、非定数プロパティの型とサイズ、定数プロパティの値です。たとえば、3 行 1 列のサイズの coder categorical 型を作成します。
c = categorical({'r','g','b'});
cType = coder.typeof(c);変数 c の表現が coder 型オブジェクト cType に格納されます。
cType =
matlab.coder.type.CategoricalType
1x3 categorical
Categories : 3x1 homogeneous cell
Ordinal : 1x1 logical
Protected : 1x1 logical
categorical coder 型の従来の coder.ClassType 表現が必要な場合は、メソッド getCoderType を使用して取得できます。たとえば、cType オブジェクトの基になる coder.ClassType 表現を確認するには、次のコマンドを使用します。
cType.getCoderType
ans =
coder.ClassType
1×1 categorical
Properties :
codes : :10×1 uint8
categoryNames : :3×1 locked homogeneous cell
base: 1×1 char
isProtected : 1×1 logical
isOrdinal : 1×1 logical
numCategoriesUpperBound : 1×1 double
オブジェクトのプロパティ
coder categorical 型オブジェクトのプロパティを編集できます。オブジェクトのプロパティにスカラー値を割り当てることができます。coder 型オブジェクトのプロパティに値を割り当てると、対応する coder 型の値に暗黙的に変換されます。オブジェクト自体のサイズを変更するには、coder.resize 関数を使用するか、オブジェクトのプロパティを直接編集します。
coder.resize を使用したオブジェクトのプロパティのサイズ変更
coder.resize を使用して、categorical オブジェクトのサイズとオブジェクトのプロパティのサイズを変更できます。プロパティ内で配列を作成することもできます。
たとえば、3 行 1 列のサイズの coder categorical 型を作成します。
c = categorical({'r','g','b'});
cType = coder.typeof(c)cType =
matlab.coder.type.CategoricalType
1x3 categorical
Categories : 3x1 homogeneous cell
Ordinal : 1x1 logical
Protected : 1x1 logical
coder.resize を使用して、Categories を上限が 3 の可変長にします。
cType.Categories = coder.resize(cType.Categories,[3 1],[true false])
cType =
matlab.coder.type.CategoricalType
1x3 categorical
Categories : :3x1 homogeneous cell
Ordinal : 1x1 logical
Protected : 1x1 logical
オブジェクトのサイズを直接変更
特定のタイプのオブジェクトについては、オブジェクトのプロパティを編集することでオブジェクト自体のサイズを変更することもできます。たとえば、cType オブジェクトの行数を変更するには、Size プロパティを編集します。
cType.Size = [10 1]
cType =
matlab.coder.type.CategoricalType
10x1 categorical
Categories : :3x1 homogeneous cell
Ordinal : 1x1 logical
Protected : 1x1 logicalVarDims プロパティを使用して行数を可変サイズにすることもできます。
cType.VarDims = [true false]
cType =
matlab.coder.type.CategoricalType
:10x1 categorical
Categories : :3x1 homogeneous cell
Ordinal : 1x1 logical
Protected : 1x1 logical参考
categorical | coder.Constant | coder.newtype | coder.typeof