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!