Extract subset of data between specified points

조회 수: 7 (최근 30일)
Brie E.
Brie E. 2020년 5월 26일
댓글: Brie E. 2020년 5월 26일
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
KSSV
KSSV 2020년 5월 26일
Attach your data. Show us what have you done.

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2020년 5월 26일
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
Brie E.
Brie E. 2020년 5월 26일
Thank you so much for your response! Working with the code you suggested - does this output the individual segments in a single cell? I'd be looking to generate the output of each segment as a double to then average the velocity values across the columns (to obtain the phase average).
I've uploaded the signal data as well as the script I was using here, in case that helps clarify.
Brie E.
Brie E. 2020년 5월 26일
Oh okay I actually got it working now. Thanks again! Coming into matlab from the Python world...learning as I go so I appreciate the help!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by