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.

 采纳的回答

Matt J
Matt J 2021-7-11
编辑:Matt J 2021-7-11
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 个评论

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?
[ymax, rowmax] = maxk(y,10);
xmax=x(rowmax)

请先登录,再进行评论。

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Line Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by