本文介绍了在向量中找到局部最大值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮助我.我使用Matlab程序.

Somebody could help me.I use Matlab program.

假设我有向量A,

A = [0 0 1 2 3 5 0 0 0 0 0 2 3 6 7 0 0 0 0 1 1 2 3 4 1]

我想从向量A中获取局部最大值和位置.因此,我想得到的答案如下.

I would like to get local maximum values and location from the vector A. So, the answer that I would like to get is following.

maxValue = 5、7和4;

maxLocation = 6、15和24;

谢谢你的帮助.

推荐答案

如果您具有信号处理工具箱,则findpeaks应该是您想要的:

If you have the Signal Processing toolbox then findpeaks should be what you want:

[pks,locs] = findpeaks(A)

作为将来的参考,您应该知道要查找的是局部最大值.如果说要找到最大值,就好像要全局最大值(在这种情况下为7).

For future reference you should know that what you want to find are local maxima. Saying that you want to find the maximum value makes it seem as if you want the global maxima (which would be 7 in this case).

这篇关于在向量中找到局部最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-03 19:34