How do I get the maximum value for x with its corresponding y value?

9 views (last 30 days)
I have 2 columns of numbers. I want to find the maximum value of the numbers in the x column and it's corresponding y value. I am not sure how to put in the code. please help

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 11 Sep 2013
Edited: Azzi Abdelmalek on 11 Sep 2013
Example
A=[1 2;3 4;47 20;5 55]
[xmax,idx]=max(A(:,1));
ymax=A(idx,2)
  3 Comments
Azzi Abdelmalek
Azzi Abdelmalek on 11 Sep 2013
That's what my code do
A=[1 2;3 4;47 20;5 55];
[xmax,idx]=max(A(:,1));
ymax=A(idx,2);
xmax
ymax
% the result
xmax =
47
ymax =
20

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!