Assign array in field struct
古いコメントを表示
class(Sis)
ans =
'struct'
length(Sis)
ans =
82
c=1
2
3
..
82
i want to create new field in struct
i want this:
Sis.b(1)=1;
Sis.b(2)=2;
..
Sis.b(82)=82;
now i want to semplify calculate
c=1:82
c=c'
>> [Sis.b]=c
Insufficient number of outputs from right hand side of equal sign to satisfy assignment.
3 件のコメント
Walter Roberson
2023 年 7 月 9 日
i want this:
Sis.b(1)=1;
Sis.b(2)=2;
Your Sis is a 1 x 82 struct. Sis.b(1) by structure expansion would be as if you had written
Sis(1).b, Sis(2).b, Sis(3).b, Sis(4).b, Sis(5).b ... Sis(82).b(1) = 1;
Sis(1).b, Sis(2).b, Sis(3).b, Sis(4).b, Sis(5).b ... Sis(82).b(2) = 2;
which is not what you want. You want the equivalent of
Sis(1).b = 1;
Sis(2).b = 2;
...
Sis(82).b = 82;
Vilém Frynta
2023 年 7 月 9 日
oh, i misunderstood. thanks
shamal
2023 年 7 月 9 日
採用された回答
その他の回答 (1 件)
Sis = struct();
Sis.b = 1:82'
Sis.b(1)
Sis.b(10)
Hope this helps.
カテゴリ
ヘルプ センター および File Exchange で Structures についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!