how to sampling the signal in order to match the two signal?
조회 수: 2 (최근 30일)
이전 댓글 표시
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
채택된 답변
Star Strider
2021년 8월 15일
The first 2 column in ‘TORQUE’ are missing, so they are removed here.
% C1 = readcell('https://www.mathworks.com/matlabcentral/answers/uploaded_files/711992/TORQUE.txt')
% nrmissing = [nnz(ismissing([C1{:,1}])) nnz(ismissing([C1{:,2}])) size(C1,1)]
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/711992/TORQUE.txt', 'VariableNamingRule','preserve');
T1 = removevars(T1,{'Var1','Var2'})
T2 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/712562/MC.txt', 'VariableNamingRule','preserve')
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.
.
댓글 수: 0
추가 답변 (1개)
Sulaymon Eshkabilov
2021년 8월 14일
% They perfectly match as you can see the plot below.
MC = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/711992/MC.txt');
Torque = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/711992/TORQUE.txt');
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
댓글 수: 3
Sulaymon Eshkabilov
2021년 8월 15일
Yes, it might be. I've written the code on online here and executed it, rightaway. I have not used a desktop matlab since my matlab license was not activated.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!