Shifting data in time
이전 댓글 표시

Hello! I have a data set containing several trials as shown in the figure. I now want to take the average of these trials, but as you can see, the trials are shifted, so when I take the average, it is not a good representation. I now want to shift the trials such that their maximum is at the same position so I can compute the average maximum.
Is there anyone with a good suggestion for this?
댓글 수: 1
KL
2017년 10월 30일
It would be easier if you provided some sample data.
답변 (3개)
KL
2017년 10월 30일
I suppose you want to synchronize all the maximums, try this in that case,
m = max(temp_data);
[a b c] = find(temp_data==m);
new_data = temp_data;
new_data(:,2) = circshift(new_data(:,2),a(1)-a(2));
new_data(:,3) = circshift(new_data(:,3),a(1)-a(3));
new_data(:,4) = circshift(new_data(:,4),a(1)-a(4));
new_data(:,5) = circshift(new_data(:,5),a(1)-a(5));
plot(new_data)
댓글 수: 4
Roos Bulthuis
2017년 10월 30일
why don't you trim down the parts you don't want? After you're done aligning, something like,
new_data = new_data(101:end-100,:);
This one trims down the first and last 100 values. Another idea is to interpolate instead of padding with nan. https://de.mathworks.com/help/matlab/ref/interp2.html
Roos Bulthuis
2017년 10월 30일
KL
2017년 10월 30일
Pleasure, good luck solving the next steps.
Piotr Osinski
2019년 2월 7일
Hi, you can use Signal Processing Toolbox (https://de.mathworks.com/help/signal/ug/align-signals-with-different-start-times.html).
At first find highest delay between signals with by itereating through every pair of signals :
delaynm = finddelay(signalN, signalM);
Then allign them to the maximal delayed signal maxDelSignal:
[maxDelSignal, signalN] = alignsignals(maxDelSignal, signalN);
Pad with NaNs or zeros to the signal with maximal size:
signalN(mSaxize) = NaN;
Now you have alligned signals and can simply compute mean value of the signals and find max.
카테고리
도움말 센터 및 File Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
