# How to get the indices corresponding to the width of a peak?

14 ビュー (過去 30 日間)
Nut 2017 年 12 月 19 日
コメント済み: Csaba 2017 年 12 月 20 日
Hi,
I'm using the findpeaks function to find the peaks of an array. After this, I should get the indices of the array corresponding to the width of the peak, both if calculated referring to the half-heigth or to the half-prominence of the peak.
Please, look at the attached images (taken from the findpeaks reference): in other words, I'm interested to find the indices corresponding to the horizontal yellow segments showed into the images.
Is there a way to do this? I'm looking for an existent function or method, but also any suggestion about the approach is welcome.
Finally, I'm also wondering about the possibility of extending this concept, i.e. to get the indices corresponding to a quote given as input, not only at 0.5*height or 0.5*prominence (as example, the width at 0.7*prominence, or at 0.3*height). Any suggestions?
Thank you so much for answering.
Kind regards.

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

### 採用された回答

Csaba 2017 年 12 月 20 日
I do not know why these 0.5*height indices are important since they actually do not have any meaning. When the peaks are overwhelming 0.5*height can be practically anywhere for a given height. Especially if the vector contains noisy data. The correct way would be to fit peaks.
But if you want to find the half value, you can use the find function and look for the 0.5*height values in the vector. Then you can choose the closest or any of the found indices as you wish. Like:
indices=find(X<height/2)
where X is your vector (or part of your vector).if you want to find the left 0.5*height value then
indice=find(X(1:peakindice)<height/2,'last')
for right indice=find(X(peakindice:end)<height/2,'first')
But if your vector is rather noisy it will not be a correct value anyway.
##### 2 件のコメント表示非表示 1 件の古いコメント
Csaba 2017 年 12 月 20 日
You are welcome.

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

### カテゴリ

Find more on Descriptive Statistics in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by