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 find the maximum value(in 2nd column) against an element(in 1st column) in a mtrix

Subject: How to find the maximum value(in 2nd column) against an element(in 1st column) in a mtrix

From: Abdul

Date: 24 Dec, 2008 20:56:02

Message: 1 of 2

I have a matrix z as below:
       z =

        1218 198
        1218 22
        1218 1441
        1218 28
        1219 34
        1219 1789

some elements of matrix z (like 1218 and 1219) in first column are being repeated. I want another matrix which shows these elements only one time with their maximum values (1441 and 1789) in the 2nd column. so the final matrix (suppose p) should be of the form:
p =

        1218 1441
        1219 1789
I am a novice in MATLAB Programming. Can anybody please help me.
Thanks in advance.

Subject: How to find the maximum value(in 2nd column) against an element(in 1st column) in a mtrix

From: John D'Errico

Date: 24 Dec, 2008 23:41:02

Message: 2 of 2

"Abdul " <spacian1@hotmail.com> wrote in message <giu7l2$g4m$1@fred.mathworks.com>...
> I have a matrix z as below:
> z =
>
> 1218 198
> 1218 22
> 1218 1441
> 1218 28
> 1219 34
> 1219 1789
>
> some elements of matrix z (like 1218 and 1219) in first column are being repeated. I want another matrix which shows these elements only one time with their maximum values (1441 and 1789) in the 2nd column. so the final matrix (suppose p) should be of the form:
> p =
>
> 1218 1441
> 1219 1789
> I am a novice in MATLAB Programming. Can anybody please help me.
> Thanks in advance.

consolidator will do this directly. Find it on
the file exchange.

http://www.mathworks.com/matlabcentral/fileexchange/8354

John

Tags for this Thread

No tags are associated with 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