trying to find peaks on a time series
20 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
i'm trying to find peaks on some time series data but when i write
i get the position of peak on locs. but i want to get the locs the same length i have x files or better if i have locs represented as 0 and 1 i can get the x values without a hassle. is there an elegant and simple way of dooing it, like the find function??
i also am trying this but obviously it takes time because of the loops, is there any simple way of dooing this in matlab.
Wayne King am 11 Jun. 2012
I'm assuming that xn in your loop above is the signal. You don't show us where xn comes from and it's not used in your call to findpeaks(). In your call to findpeaks, you use x. So If that is the case, then you don't need a loop.
newx = zeros(size(x));
newx(locs) = 1;
Does the same thing as your loop.
Weitere Antworten (1)
Wayne King am 12 Jun. 2012
Then please compare:
x = [2 12 4 6 9 4 3 1 19 7];
[pks,locs] = findpeaks(x);
% here is your code
Now what I answered:
newx2 = zeros(length(x),1);
newx2(locs) = 1;
That returns a 1 for me.
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!