Error while finding peak value and location

5 ビュー (過去 30 日間)
Josh
Josh 2022 年 6 月 23 日
コメント済み: Josh 2022 年 6 月 23 日
As I try to find the peak value and peak position, the function is not executing for the same because of some error. Please help.
load 'vv.mat'
load 'cc.mat'
for m = 1:numel(vv)
[pks{m},locs{m}]=findpeaks(cc{m}(end,:), vv{m}(end,:));
end
Error using findpeaks
Expected X to be strictly increasing.

Error in findpeaks>parse_inputs (line 236)
validateattributes(Xin1,{'numeric'},{'real','finite','vector','increasing'},'findpeaks','X');

Error in findpeaks (line 135)
= parse_inputs(isInMATLAB,Yin,varargin{:});

採用された回答

MJFcoNaN
MJFcoNaN 2022 年 6 月 23 日
編集済み: MJFcoNaN 2022 年 6 月 23 日
Hello,
You should sort the "x" variable ("vv" in your code) before calling findpeaks
load 'vv.mat'
load 'cc.mat'
for m = 1:numel(vv)
cc0=cc{m}(end,:);
vv0=vv{m}(end,:);
[vv_s, ind]=sort(vv0);
cc_s=cc0(ind);
[pks{m},locs{m}]=findpeaks(cc_s, vv_s);
end
But then you have to add more limitation on how the peaks look like, for example their height, width, distance and so on. The more details you provide, the better findpeaks works.
  1 件のコメント
Josh
Josh 2022 年 6 月 23 日
Thanks for the answer.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by