Extract subset of data between specified points
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Brie E.
el 26 de Mayo de 2020
Comentada: Brie E.
el 26 de Mayo de 2020
Hi, I am working with a velocity time series signal that is generally sinusodial in nature. I am looking to extract the data points between the zero "up-crossings" (where the signal crosses the x-axis on a positive slope) to obtain phase-locked intervals. I was able to extract the coordinates of all of the crossings throughout the signal but now I am looking to extract the data between these coordinates.
Any suggestions for an efficient way to extract and output these sets of data?
Thanks in advance!
1 comentario
Respuesta aceptada
Image Analyst
el 26 de Mayo de 2020
I'd use findpeaks() to find the peaks and valleys
[peakValues, indexesOfPeaks] = findpeaks(signal);
[valleyValues, indexesOfValley] = findpeaks(-signal);
valleyValues = -valleyValues;
Then you can extract just the part of the signal that goes from valley to peak
startingPeakIndex = 1;
% Make sure peak starts after valley.
if indexesOfPeaks(1) < indexesOfValley(1)
startingPeakIndex = 2;
end
% Scan signal extracting each uprising segment.
for k = 1 : length(indexesOfValley)
thisSegment{k} = signal(indexesOfValley(k) : indexesOfPeaks(startingPeakIndex + k - 1));
end
You will have to play around with findpeaks() to get the right parameters to pick out just the major peaks and not the small noise peaks. It might help to use sgolayfilt() with a polynomial order of 5 or more to smooth the sinusoid before calling findpeaks().
Attach your data in a .mat file if you need more help.
save('answers.mat', 'signal');
2 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!