Minimum and maximum values of a field in a structure array

조회 수: 7(최근 30일)
Hi. I have a strcuture array with 10 fields. How can, I find the minumum and maximum values of a particular field f1? I tried uisng min and max commands but, they are giving wrong results.
For example,
The name of the structure array is "Test" (1 x 5000) and the field name is "growth". I want the minimum and maximum of the whole field growth.
Test(1).growth=[1 2 3 4 5 5 6 7 8 9];
Test(2).growth=[10 20 40 67];
..... so on.
I want the maximum and the minimum of the field "growth".
  댓글 수: 2
SS
SS 2019년 8월 25일
편집: SS 2019년 8월 25일
The name of the structure array is "Test" (1 x 5000) and the field name is "growth". I want the minimum and maximum of the whole field growth.
Test(1).growth=[1 2 3 4 5 5 6 7 8 9];
Test(2).growth=[10 20 40 67];
..... so on.
I want the maximum and the minimum of the whole field growth.

댓글을 달려면 로그인하십시오.

채택된 답변

Bruno Luong
Bruno Luong 2019년 8월 25일
arrayfun(@(s) min(s.f1), s)
  댓글 수: 3
SS
SS 2019년 8월 25일
편집: SS 2019년 8월 25일
Thanks, will do it from next time onwards.

댓글을 달려면 로그인하십시오.

추가 답변(0개)

범주

Find more on Operators and Elementary Operations 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!

Translated by