FindPeaks() of a 1024 x 116 Matrix

15 visualizaciones (últimos 30 días)
Christopher Gordon
Christopher Gordon el 18 de En. de 2021
Comentada: dpb el 19 de En. de 2021
I have a matrix that I read into MatLab that is 116 spectra (columns) each being 1024 elements (rows). Each spectrum has a peak and I'm looking to determine the following information from each spectrum:
- Peak value
- Peak position
- Peak width at a set height, like 10% or 30% of the peak height. What I'd really like is to know the first and last x element of each peak
I've completed the Signal Processing Toolbox course and it didn't go over the FindPeaks() function. Please, any help would be greatly appreciate. Even if it's direction to a good source on the function. Thank you!

Respuesta aceptada

dpb
dpb el 18 de En. de 2021
Editada: dpb el 19 de En. de 2021
findpeaks only works on vector input; just use a loop and pass each column of your array in turn.
There's a fair amount of background information and examples of using findpeaks in the documentation; I'm unaware of any other tutorial but the web if full of stuff.
I'd suggest "just try it" and see what you get. If the spectra are only one-peaked, it seems it could hardly go wrong.
ADDENDUM
Since findpeaks can return anything from an empty set to some large number of peaks, you'll probably want to use a cell array to store the results initially or else wrap the call into a routine that processes the results of each column to ensure expected results rather than just presume every column will give one and only one peak. Of course, if the data are very clean, that may actually happen....I was rarely that lucky. :)
  5 comentarios
Christopher Gordon
Christopher Gordon el 19 de En. de 2021
Sorry, just a quick follow up. For the threshold, is that a fraction of the total signal, or do I need to specify an exact value? Each curve has one main peak and may have smaller features, but the peak will be an order or more larger in magnitude.
dpb
dpb el 19 de En. de 2021
'Threshold' is absolute but it's probably not what you want here; it's more for isolating a peak from multiple sidelobe-type peaks that are relatively close in amplitude.
Since you think your spectra are just one dominant peak and want only it, I'd think
[peak,locs,width] = findpeaks(AllCurves(:,curve),'NPeaks',1,'SortStr','descend');
would be the way to go. The documentation for 'NPeaks' is a little misleading, perhaps, in that one might infer that only the first peak positionally would be returned which would be true if didn't also use the illnamed 'Sortstr' parameter along with it.
The doc should make a note that when used together all peaks will be found, sorted and then only the requested number returned, sorted as requested. 'none' as the choice there is the same as if didn't use the 'Sortstr' parameter at all, it will return in the order in the input vector.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by