Struct using an Index?

3 ビュー (過去 30 日間)
Peter Meier
Peter Meier 2020 年 7 月 21 日
コメント済み: Stephen23 2020 年 7 月 21 日
Hi,
I have a struct 1*100 with 33 Fields. I would like to write this struct several times and then access the respective struct (which always has the same name) with an index. Index 1 = struct 1 / index 2 = struct 2. Is this working? I dont want to use different names for each struct. Thanks.

採用された回答

Arthur Roué
Arthur Roué 2020 年 7 月 21 日
Yes, you can totally creat a structure array.
s(1) = struct('f1','a','f2', 1)
% Add a value to field f2 in element 3
s(3).f2 = 3;
% s(2) is empty
s(2).f1
  4 件のコメント
Peter Meier
Peter Meier 2020 年 7 月 21 日
The field names and the size are always the same only the data is different. I want to call the struct always with the same name but with another index. its like 1000 3x3 Matrix with the same name. like structA{1} / structA{2}
Walter Roberson
Walter Roberson 2020 年 7 月 21 日
S(3,75).A . /S(1,75).A
for example

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by