MATLAB に構造があります。フィールドにアクセスしようとすると、次のように表示されます。
[4158x5 double]
配列自体を取得するにはどうすればよいですか?
MATLAB に構造があります。フィールドにアクセスしようとすると、次のように表示されます。
[4158x5 double]
配列自体を取得するにはどうすればよいですか?
私の推測では、構造体フィールドに格納されている行列はセル配列にカプセル化されているため、中括弧{}
を使用してセルの内容にインデックスを付ける必要があります(つまり、コンテンツのインデックス付け)。次の例を検討してください。
>> S.field1 = {1:5}; %# Create structure S with field 'field1' containing a cell
%# array which itself contains a 1-by-5 vector
>> S.field1 %# Index just the field...
ans =
[1x5 double] %# ...and you see the sort of answer you were getting
>> S.field1{1} %# Index the field and remove the contents of the cell...
ans =
1 2 3 4 5 %# ...and now you get the vector
注: MATLAB の新しいバージョンでは、表示が少し異なるため、この混乱を避けることができます。表示される内容は次のとおりです。
>> S.field1
ans =
cell % Note now that it displays the type of data
[1×5 double]