Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使用该plot功能标记峰值?
plot
例子:
a = [0 1 3 23 3 9 10 28 2] [p,locs] = findpeaks(a)
结果:</p>
p = 23 28 locs = 4 8
您不提供 x 范围,因此创建一个(您可以将其更改为您想要的)。
figure x = [1:length(a)]; plot(x,a,'k');
上面绘制了您的原始数据点,以下将
hold on plot(locs,p,'ro');
将您的峰值绘制为原始系列顶部的红色圆圈点。如果您需要非整数 x 范围,则需要计算与locs数组中的索引对应的适当值,并改用这些 x 值。
locs