FindPeaks() of a 1024 x 116 Matrix
12 次查看(过去 30 天)
显示 更早的评论
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!
0 个评论
采纳的回答
dpb
2021-1-18
编辑:dpb
2021-1-19
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 个评论
dpb
2021-1-19
'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.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!