简体   繁体   中英

matlab identify position of min and max

I have a time series and have calculated the min, max and mean values. However, I want to know at which year the min and max observations occurred. How is it possible to identify the ith position of the min and max values in the dataset?

You find it using find command.

for example:

M = [1992, 3 ,5; 1997, 8 ,2; 2000, 2, 15]
[~,min_i] = min(M(:,2)) %return the row index of min vaule in the 2nd column.
year_of_min = M(min_i,1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM