targeting a single piece of data from an array

I have an array of values, 5 columns, 30 rows. Trying to get a min and max from the array, but all that gets returned is the whole row of data, being the row with the lowest values, and the row with the highest values. what i need is the single lowest value and single highest value.
Thanks.

답변 (2개)

Andrei Bobrov
Andrei Bobrov 2013년 2월 27일

1 개 추천

[z,ii] = min(x(:));
[rws,cls] = ind2sub(size(x),ii);
Honglei Chen
Honglei Chen 2013년 2월 27일

0 개 추천

min(min(x))
and
max(max(x))
Or
min(x(:))
and
max(x(:))

댓글 수: 2

Tyler
Tyler 2013년 2월 27일
that worked great, is there anyway to also denote which row this came from?
like if the columns were years and the rows were weeks, so it would show that it came from row 5 (meaning the 5th week)?
There are two ways to do this. One way is to do as @Andrei showed above, or you can do this in two steps as I show below
[temp,weekidx] = min(x);
[y,minYear] = min(temp);
minWeek = weekidx(minYear)

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

카테고리

도움말 센터File Exchange에서 NaNs에 대해 자세히 알아보기

질문:

2013년 2월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by