Plot x values corresponding to n max y values in a table

I have excel data imported as a table and want to display 5 max y values and then plot them against their corresponding x value. i am unable to get matlab to find the corresponding x values.

 Respuesta aceptada

Matt J
Matt J el 11 de Jul. de 2021
Editada: Matt J el 11 de Jul. de 2021
i am unable to get matlab to find the corresponding x values.
It's unclear how you've been approaching it, but if you are using the the maxk() function, calling it with two output arguments should give you both the y-values and the x-values (or at least their row indices) pretty straightforwardly.

3 comentarios

Hi,
Table = xlsread('newfile.xlsx','Sheet1');
x = Table(:,1);
y = Table(:,2);
B = maxk(y,10)
This is how I was approaching it. What do you mean by two output arguments?
Matt J
Matt J el 11 de Jul. de 2021
Editada: Matt J el 11 de Jul. de 2021
[ymax, rowmax] = maxk(y,10);
xmax=x(rowmax)
Thank you so much!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Line Plots en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 11 de Jul. de 2021

Comentada:

el 11 de Jul. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by