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일

0 개 추천

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일
I understand. The name of this struct is s. But i want for example 899 1*3 structs with 2 fields with the name s. Not a 1*899 struct with 2 fields. Thx for your help. I hope you understand
Walter Roberson
Walter Roberson 2020년 7월 21일
use an 899 x 3 struct if the field names are always the same. Or a 3 x 899 would be slightly more efficient if you are accessing in groups of 3
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개)

카테고리

도움말 센터File Exchange에서 Structures에 대해 자세히 알아보기

태그

질문:

2020년 7월 21일

댓글:

2020년 7월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by