在MATLAB

时间:2015-07-25 17:00:15

标签: matlab fft

我有兴趣找到此图的x轴的最终值。

[MATLAB Plot[1]

我已尝试使用Xlim命令获取沿x轴的值范围,但它给出了整个图形的范围([0 250000])而不是图形的最终值,位于~22000赫兹左右。 MATLAB中有一个函数可以为我找到这个值吗?

2 个答案:

答案 0 :(得分:2)

假设你的x值在变量' x'只是做:

max(x)

答案 1 :(得分:2)

我假设你想从图中获得的值,也就是说,你无法访问产生图形的变量。

获取绘制曲线的'XData''YData',然后查找 x 值最大的点:

ch = get(gca, 'Children'); %// all children of current axes
ch = findobj(ch, 'type', 'line'); %// keep only line objects
xData = get(ch(1), 'XData'); %// take first line object, if there are more than one
yData = get(ch(1), 'YData');
[resultX, ind] = max(xData); %// resultX is the greatest x value in the graph
resultY = yData(ind); %// resultY is the corresponding y value