構造体配列の要素の参照方法について
Afficher commentaires plus anciens
初歩的な質問で大変恐縮なのですが、
s.a = 1
s.b = [1,2]
s.c = 'test'
のような構造体配列sがある時、要素を指定する際にs.aと文字を使って指定するのではなく、s(1)がs.a, s(2)がs.bを指定しているのと同義になるような、数値を用いて指定することはできないでしょうか。
Réponse acceptée
Plus de réponses (1)
こんにちは.
関数 struct2cell を使うのがいちばん手っ取り早いかと思います.
s.a = 1;
s.b = [1,2];
s.c = 'test';
c = struct2cell(s);
c{1}
c{2}
c{3}
1 commentaire
takeru misawa
le 13 Sep 2021
Catégories
En savoir plus sur 構造体 dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!