How to calculate the synchronization error using signal time shifting

조회 수: 3 (최근 30일)
Proman
Proman 2021년 11월 10일
댓글: Mathieu NOE 2021년 11월 12일
Hello and Good day
I have a problem regarding calculating the following equation which is called synchronization error. the expressions in the angle brackets are mean() function. My major problem lies in the term corresponding to time shifting, which is PR(t + delta_t). I used every kind of interpolation and extrapolation methods yet the answers have been quite out of range yet.
I also searched other similar questions regarding this matter yet the answers were not helpful to my matter. The data is attached. by the way the parameter a, a = 2 in the above equation. thanks for your time devoted to my problem

채택된 답변

Mathieu NOE
Mathieu NOE 2021년 11월 10일
Hello
this is a code that will do the time shifting and sigma computation for a time shift of - 10 to + 10 samples
seems the two signals are pretty well time aligned as the error is minimal for a delta of 0 sample
now we could refine the analysis if we would resample the data with a smaller time increment.
you can uncommet those lines if you want to see the effect of time shift on the data - but this is not a key point here
% figure(1)
% plot(tra2,Pt2,tra2,Pra2)
% pause(1)
full code :
clc
clearvars
%% load('');
load('dataP.mat')
dt = mean(diff(t));
a = 2;
Pra = Pr/a; % normalize Pr data by factor a
%% main code
samples = 10;
delta_samples = (-samples:samples);
delta_t = delta_samples*dt;
for ci = 1:numel(delta_samples)
tra = t+delta_t(ci);
% find common time axis
ind = (tra>=min(t) & tra<=max(t));
tra2 = tra(ind);
Pra2 = Pra(ind);
% resample Pt data on time axis of Pra2 data (tra2)
Pt2 = interp1(t,Pt,tra2,'linear');
% figure(1)
% plot(tra2,Pt2,tra2,Pra2)
% pause(1)
% error (cf equation)
num = mean((Pt2(:)-Pra2(:)).^2);
den = mean((Pt2(:)).^2);
sigma(ci) = num./den;
end
figure(2)
plot(delta_t,sigma);
xlabel('Delta Time (s)');
ylabel('Sigma error');
title('Synchronization Error using Signal Time Shifting');
  댓글 수: 2
Proman
Proman 2021년 11월 11일
Dear Mathieu
Special thanks to your help. Wonderfully done!
Can you just explain a bit about the stuff in the loop? I mean these parts:
tra = t+delta_t(ci);
% find common time axis
ind = (tra>=min(t) & tra<=max(t));
tra2 = tra(ind);
Pra2 = Pra(ind);
% resample Pt data on time axis of Pra2 data (tra2)
Pt2 = interp1(t,Pt,tra2,'linear');
To my opinion, this algorithm of yours can not only be used for signal shifting, but also for time reversal and signal scaling, am I right?
Mathieu NOE
Mathieu NOE 2021년 11월 12일
hello Quantum
tra : we create a time shifted version of t for data Pra
of course to do the sigma error computation both data Pt and Pra must have same length so we have to keep only the common part of both data sets. this new common time axis (data) is tra2;
then we have to compute the Pt data for this truncated time vector so that's why we use interp1 function to have Pt data for tra2 time vector
after that the sigma error computation is straightforward
yes , in a similar manner you could do time reversal
signal scaling for me is simply correcting y scale so that is the factor a in your code

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Signal Attributes and Indexing에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by