# how to sampling the signal in order to match the two signal?

3 views (last 30 days)
Keshasni Earichappan on 14 Aug 2021
Answered: Star Strider on 15 Aug 2021
Hi.i am having trouble to set both data (mc & torque) on the same time axis.MC-voltage signal need to sampled at 5 kHz and low-pass filtered with a cutoff frequency 10 Hz in order to match with the torque(maybe).Basically,I need to match the two different time series into one same time series.Hope anyone can help me to figure it out.Thanks in advance
dpb on 14 Aug 2021
Look at resample in Signal Processing Toolbox...

Star Strider on 15 Aug 2021
The first 2 column in ‘TORQUE’ are missing, so they are removed here.
% nrmissing = [nnz(ismissing([C1{:,1}])) nnz(ismissing([C1{:,2}])) size(C1,1)]
T1 = removevars(T1,{'Var1','Var2'})
T1 = 7967×2 table
TIME TORQUE ____ ______ 0 0 10 0.7 20 1.1 30 6.5 40 6.5 50 6.4 60 6.5 70 6.4 80 6.1 90 6.1 100 6.4 110 7.1 120 7.9 130 8.3 140 7.9 150 8
T2 = 90483×2 table
Time MC[v] ________ ______ 0 1.8297 0.000999 1.8289 0.001998 1.8297 0.002997 1.8297 0.003996 1.8305 0.004996 1.8289 0.005996 1.8297 0.006997 1.8313 0.007996 1.8305 0.008995 1.8281 0.009994 1.8297 0.010995 1.8305 0.011994 1.8305 0.012995 1.8297 0.013994 1.8297 0.014993 1.8305
Fs = 100; % Resample To 100 Hz Sampling Frequency
[TORQUEr,T_TIMEr] = resample(T1.TORQUE, T1.TIME, Fs);
[MCvr,V_TIMEr] = resample(T2.('MC[v]')-mean(T2.('MC[v]')), T2.Time, Fs);
MCvr = MCvr + mean(T2.('MC[v]'));
figure
subplot(2,1,1)
plot(T_TIMEr, TORQUEr)
grid
xlabel('t')
ylabel('Torque (Resampled)')
subplot(2,1,2)
plot(V_TIMEr, MCvr)
xlabel('t')
ylabel('MC[v] (Resampled)')
grid They both have the same 100 Hz sampling frequencies, however they retain significantly different time vectors.
.

Sulaymon Eshkabilov on 14 Aug 2021
% They perfectly match as you can see the plot below.
plot(MC.TIME, MC.TORQUE, 'bx', Torque.TIME, Torque.TORQUE, 'r'), legend('MC','Torque') % If you need to resample them then, apply resample()
% See here: https://www.mathworks.com/help/signal/ref/resample.html
Keshasni Earichappan on 15 Aug 2021
hi @Scott MacKenzie & @Sulaymon Eshkabilov....sorry i had attached the wrong MC.txt file jn..here i have attached the updated one..I need to match the two different time series into one same time series(sampling period).Is it possible? :)