How to manipulate some data inside a structure array?
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi all,
I have to calculate some areas from some different hydraulic cross section datasets, i think it won't be a problem with trapz function. With a help i managed to build a structure array "called" sections where there are all the cross sections as field and another substructure as a value with station and elevation data of the hydraulic cross section
When i try to calculate minimum elevation (inside a for cycle used to extract data from a .gxx file) i manage to see the loop with all the elevation data in the command window but in the workspace the variable is only the last value of the matlab calculation
The struct is written in this way: Sezioni.(sez_name).station = sez1(:,2)'
sez_name is composed by 191 "char" fields with name of the c.s., the value is another 1x1 structure with station (x) and elevation (y) data. I have to calculate the minimum elevation for all fields, not only for the last. How can I do? Thank you for the help.
댓글 수: 1
Mario Malic
2021년 5월 1일
Hey Virgilio,
When you ask for some inputs from structure, there are cases where the output will result in something like this
data = struct();
tempstruc = struct('a', [1; 2], 'b', [2; 3]);
data.a(1).station = tempstruc;
data.a(2).station = tempstruc;
data.b.station = [2 3 4;
1 4 5];
[data.a.station]
data.a.station
If you see the last line, this is how your output looks like, ans is being constantly replaced and your next line will only take the last value for it.
It is hard to visualize how is your structure formed. I'd suggest you to create a simpler and similar structure and try to figure out how you should do things on it.
Take a look also at functions fieldnames.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Structures에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!