Minimum and maximum values of a field in a structure array
2 次查看(过去 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 个评论
采纳的回答
Bruno Luong
2019-8-25
arrayfun(@(s) min(s.f1), s)
3 个评论
Bruno Luong
2019-8-25
编辑:Bruno Luong
2019-8-25
I recommend you to post your data the next time asking question. You'll save time and us too.
arrayfun(@(s) min(s.growth), Test)
更多回答(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!