Struct using an Index?
1 view (last 30 days)
Show older comments
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.
Accepted Answer
Arthur Roué
on 21 Jul 2020
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 Comments
More Answers (0)
See Also
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!