Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How to calculate maximum & minimum multiple column values?

Subject: How to calculate maximum & minimum multiple column values?

From: Mohd Farhan

Date: 6 Dec, 2011 12:04:08

Message: 1 of 4

hello,

Let suppose i have 10 different values column-wise from n=1 to 10.

n - values
--------------
1 - 22
2 - 42
3 - 41
4 - 99
5 - 99
6 - 98
7 - 77
8 - 09
9 - 81
10 - 01

Now if we apply "d=max(n)" it will give 99.
but i want to know at which "level of n" it is having maximum value. i.e. how can i know that n=4 & 5 has maximum value 99!!??

How can i calculate that?

please help..

thanks in advance..

Subject: How to calculate maximum & minimum multiple column values?

From: someone

Date: 6 Dec, 2011 15:13:09

Message: 2 of 4

"Mohd Farhan " <farhan7787@gmail.com> wrote in message <jbl0bo$lcg$1@newscl01ah.mathworks.com>...
> hello,
>
> Let suppose i have 10 different values column-wise from n=1 to 10.
>
> n - values
> --------------
> 1 - 22
> 2 - 42
> 3 - 41
> 4 - 99
> 5 - 99
> 6 - 98
> 7 - 77
> 8 - 09
> 9 - 81
> 10 - 01
>
> Now if we apply "d=max(n)" it will give 99.
> but i want to know at which "level of n" it is having maximum value. i.e. how can i know that n=4 & 5 has maximum value 99!!??
>
> How can i calculate that?
>
> please help..
>
> thanks in advance..

doc max

Use the form:

[C,I] = max(A)

finds the indices of the maximum values of A, and returns them in output vector I. If there are several identical maximum values, the index of the first one found is returned.

If you want to find ALL of the indicies, you will probably have to then use find.
Something like:

ind = find(A>=C)

Subject: How to calculate maximum & minimum multiple column values?

From: Mohd Farhan

Date: 7 Dec, 2011 19:00:08

Message: 3 of 4

"someone" wrote in message <jblbe4$sdg$1@newscl01ah.mathworks.com>...
> "Mohd Farhan " <farhan7787@gmail.com> wrote in message <jbl0bo$lcg$1@newscl01ah.mathworks.com>...
> > hello,
> >
> > Let suppose i have 10 different values column-wise from n=1 to 10.
> >
> > n - values
> > --------------
> > 1 - 22
> > 2 - 42
> > 3 - 41
> > 4 - 99
> > 5 - 99
> > 6 - 98
> > 7 - 77
> > 8 - 09
> > 9 - 81
> > 10 - 01
> >
> > Now if we apply "d=max(n)" it will give 99.
> > but i want to know at which "level of n" it is having maximum value. i.e. how can i know that n=4 & 5 has maximum value 99!!??
> >
> > How can i calculate that?
> >
> > please help..
> >
> > thanks in advance..
>
> doc max
>
> Use the form:
>
> [C,I] = max(A)
>
> finds the indices of the maximum values of A, and returns them in output vector I. If there are several identical maximum values, the index of the first one found is returned.
>
> If you want to find ALL of the indicies, you will probably have to then use find.
> Something like:
>
> ind = find(A>=C)

it is not working!!

for: [C,I] = max(A)
it is displaying: ??? Too many output arguments.

& for ind = find(A>=C)
it is displaying: 1

what to do!!!! please help..

Subject: How to calculate maximum & minimum multiple column values?

From: Mohd Farhan

Date: 7 Dec, 2011 19:11:09

Message: 4 of 4

thanks i got answer.. thanks for ur reply..

& here it is:

Let "a" be a matrix.. then apply:

[row_val row_ind] =max(a, [], 1);
[col_val col_ind] =max(row_val)

^^it will give max value with value of column.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us