【问题标题】:Findpeaks coordinates not matching X axis coordinates (Matlab)Findpeaks坐标与X轴坐标不匹配(Matlab)
【发布时间】:2020-02-29 23:04:05
【问题描述】:

我有一段代码没有按预期执行(至少在我看来),我希望有人能帮助澄清这个问题。

代码绘制了我的数据的直方图,并应用 ksdensity 函数来平滑数据,最后它运行 findpeaks 函数以返回绘制的最大值。但是,横轴坐标与绘制数据的图形表示不对应。

MB(A); %array with the data to be plotted
figure;
histogram(MB(A),25)

[f,xi] = ksdensity(MB(A), 'Bandwidth',10);
figure;
plot(xi,f);
[peaks,loc] = findpeaks(f) 

这段代码的结果是:

峰 = 0.0232 0.0017
位置 = 27 76

然而,在查看图形表示时,峰值的坐标(对于水平轴)与这些值非常不同

histogram smoothed data

我最初认为这可能是拟合过度或拟合不足的问题,但在稍微调整一下这些值之后,问题仍然存在。我只是缺少一些基本概念吗?任何帮助将不胜感激。非常感谢

【问题讨论】:

    标签: matlab plot figure smoothing


    【解决方案1】:

    [loc] 位置是该点的 index,因此您可以通过以下方式获得图形 x:

    xi(loc)
    

    有关返回变量的信息,请参见 matlab 帮助:

    [PKS,LOCS]= findpeaks(Y) also returns the indices LOCS at which the
        peaks occur.
    

    【讨论】:

      猜你喜欢
      • 2020-07-16
      • 1970-01-01
      • 2011-12-04
      • 1970-01-01
      • 1970-01-01
      • 2018-02-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多