MATLAB Answers

Maximum and Minimum values of a field structure array

조회 수: 6(최근 30일)
Rishitha Muchinthala
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.

  댓글 수: 0

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

답변(1개)

Birdman
Birdman 2 Apr 2020
%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

표시 이전 댓글 수: 5
Rishitha Muchinthala
Please find the matlab file attached below.
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)"
Rishitha Muchinthala
Thank you,
Akira's second code is working.
I got the result.

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

Community Treasure Hunt

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

Start Hunting!

Translated by