在MATLAB中获取向量中的绝对峰位置 [英] Get absolute peak location in a vector in MATLAB

查看:72
本文介绍了在MATLAB中获取向量中的绝对峰位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个像这样的A矩阵:

Suppose I have the A matrix like this:

A =    [0,0,0,0,0,0,106,10,14,20,20,23,27,26,28,28,28,23,28,28,21,18,106,14,12,
17,16,15,22,19,20,18,21,23,23,18,17,15,106,28];

>>  plot(A)

我想要此数据集中的峰的索引.在此示例中,我要寻找的答案是一个矩阵,其中包含将数据光标"放在绝对峰上时曲线中的x值.

I want the index of the peaks in this dataset. The answer that I'm looking for in this example, is a matrix which contains those x value in your curve when you put the "data cursor" on absolute peaks.

我想要的答案是:K = [7 23 39]这是峰的位置.

The answer I want is: K = [7 23 39] which is the locations of the peaks.

当我在MATLAB中使用plot命令时,峰清晰可见.如何找到绝对峰的x值?有可能吗?

When I use the plot command in MATLAB, the peaks are clearly visible. How can I find the x value of absolute peaks? Is it possible?

推荐答案

这并不能为您提供所有的峰,但可以为您提供该组中的最大值:

This does not give you all the peaks, but it gives you the maximum value in the set:

max_locations = find(A==max(A))

如果要查找峰,请使用findpeaks函数:

If you want to find the peaks, use the findpeaks function:

[peakVal,peakLoc]= findpeaks(A);

这篇关于在MATLAB中获取向量中的绝对峰位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆