Finding several local maximum values in a given range and corresponding indices

28 ビュー (過去 30 日間)
FW
FW 2019 年 9 月 27 日
回答済み: Image Analyst 2019 年 9 月 28 日
If we have a dataset "y" which consists of a sum of 5 gaussian peaks as function of time t, there will be 5 local maximum values in the whole y values. Basically, I would like to obtain the y axis maximum values and their corresponding t axis values. For example peak 1, has a maximum value 5 and it corresponds to t value of 19.
untitled.jpg
One can individually find the maximum values by giving a range say
[a ,i]=max(y(1:20));% locating maxima in a given range of the first peak
value_1= t(i); % Corresponding value of time for index i1.
One can repeat this 5 times by specifying the ranges for all peaks. Is there a better way to achieve the same result as an output in a single vector, and the corresponding time for those maxima in another vector . Thanks.
  2 件のコメント
madhan ravi
madhan ravi 2019 年 9 月 27 日
If you mean all the indices of the max value:
Indices = find(y==max(y(:))
FW
FW 2019 年 9 月 27 日
I have edited the question to clarify it. Basically, I would like to obtain the y axis maximum values and their corresponding t axis values. For example peak 1, has a maximum value 5 and it corresponds to t value of 19. I want to have all the 5 values of maximum and their corresponding time values?

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

採用された回答

Star Strider
Star Strider 2019 年 9 月 27 日
Use the Signal Processing Toolbox findpeaks function, or the islocalmax (R2017b and later) function.
  8 件のコメント
MW
MW 2019 年 9 月 28 日
That sounds good, will try that. I hope Matlab includes peak area determination just like OriginPro where one can pan the area of interest and determine its area.
Star Strider
Star Strider 2019 年 9 月 28 日
Thank you.
I hope Matlab includes peak area determination just like OriginPro where one can pan the area of interest and determine its area.
I doubt that’s an option, or if it is, I’ve not heard of it.
Fitting Gaussians is not difficult. See: Area under each peak for an illustration, including findpeaks calls. You can probably use that code with a few tweaks to use your own data. (I will help as necesary, since it’s my code. That code uses trapz, however it would probably not be very difficult to tweak it to use integral to calculate the areas, once the parameters of the Gaussians are known.)

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2019 年 9 月 28 日
It looks like you already have an acceptable answer, but if you want code to fit some specified number of Gaussians to a signal, let me know - I have that, though not in a general purpose demo right now (I'd have to create that). Attach your signal if you need this.

カテゴリ

Help Center および File ExchangeSpectral Estimation についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by