how to sampling the signal in order to match the two signal?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Keshasni Earichappan
el 14 de Ag. de 2021
Respondida: Star Strider
el 15 de Ag. de 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
1 comentario
Respuesta aceptada
Star Strider
el 15 de Ag. de 2021
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 comentarios
Más respuestas (1)
Sulaymon Eshkabilov
el 14 de Ag. de 2021
% 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 comentarios
Sulaymon Eshkabilov
el 15 de Ag. de 2021
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.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!