フィルターのクリア

how to make matlab functions work not starting at the first element

5 ビュー (過去 30 日間)
Naufal Arfani
Naufal Arfani 2021 年 1 月 25 日
編集済み: Mischa Kim 2021 年 1 月 25 日
I want to try to figure out how the findpeaks function doesn't work on the first array element, so suppose i have this code
a = [2 5 2 4 2 7 2 2 2 5 2];
pks = findpeaks(a);
but I don't want the first 5 to be read by findpeaks so it looks like it's just skipped, what code do I need to add? thank you for your attention

回答 (1 件)

Mischa Kim
Mischa Kim 2021 年 1 月 25 日
編集済み: Mischa Kim 2021 年 1 月 25 日
Hi Naufal, how about:
a = [2 5 2 4 2 7 2 2 2 5 2];
pks = findpeaks(a);
mypks = pks(2:end);
To be able to skip the first peak, you (well, MATLAB) needs to know/identify this first peak. So an easy "workaround" is to let MATLAB compute all peaks and then omit the first one by extracting all peaks starting with the second.

カテゴリ

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

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by