フィルターのクリア

Utilizing "maxk" function in series of vectors

1 回表示 (過去 30 日間)
Daeyeon Koh
Daeyeon Koh 2021 年 9 月 2 日
編集済み: Matt J 2021 年 9 月 2 日
Hi. I used "findpeaks" function, and get peak datas in vector(pks, locs): "locs" means the X value.
And I wanna get 4 peak datas in vector in order to "locs" value like the loaded picture in red grid (in the range of 1<locs<10).
But according to the present code, I can only get seperate "maxk" values for each pks and locs.
How can I get desirable vector array like the picture?
for n=1:col-2
y=numbers(:,col);
ys=smooth(y,50,'sgolay',5);
[pks,locs] = findpeaks(ys,x,'MinPeakDistance',0.5);
A{n}=[pks,locs];
B{n}=maxk(A{n,1}(locs>1&locs<10,:),4);
end

採用された回答

Matt J
Matt J 2021 年 9 月 2 日
編集済み: Matt J 2021 年 9 月 2 日
for n=1:col-2
y=numbers(:,col);
ys=smooth(y,50,'sgolay',5);
[pks,locs] = findpeaks(ys,x,'MinPeakDistance',0.5);
[~,idx]=maxk( pks(locs>1&locs<10) ,4);
A{n}=[pks,locs];
B{n}=A{n}(idx,:);
end
  2 件のコメント
Daeyeon Koh
Daeyeon Koh 2021 年 9 月 2 日
Hi Matt, and thank you for your help.
I understand usability of indexing.
By the way, although I set the locational range (locs>1&locs<10), it looks like "locs>1" doesn't work.
(the picture below is a result when sorting idx: sort(idx))
How to solve this problem?
Matt J
Matt J 2021 年 9 月 2 日
編集済み: Matt J 2021 年 9 月 2 日
To troubleshoot, we need to see pks and locs. I suggest attaching them in a .mat file.

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

その他の回答 (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