Maximum and Minimum values of a field structure array

13 次查看(过去 30 天)
Hi, I have structure array as shown in the image below. How can i find the maximum and minimum population with the corresponding state for the available data.
Thanks in advance.

回答(1 个)

Birdman
Birdman 2020-4-2
%find max and min population
[Cmax,maxIdx]=max(AustralianStates.Population)
[Cmin,minIdx]=min(AustralianStates.Population)
%find corresponding state
AustralianStates.Name([minIdx maxIdx])
%find corresponding land area
AustralianStates.Land_Area([minIdx maxIdx])
  8 个评论
Rishitha Muchinthala
Hi @Akira Agata,
I tried the first code and i got the below error.
"Expected one output from a curly brace or dot
indexing expression, but there were 8 results.
Error in A2_19508724 (line 108)
AustralianStates.Name(maxIdx)"

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by