How to compare two time signals with different amount of samples?
1 view (last 30 days)
I have two vectors. Both vectors contain values for a time signal over 2500 ms. Vector1 has 2500 samples (1 kHz) and Vector2 has 2560 samples (1,024 kHz).
My goal is to create a diff between these two vectors in order to see the differences between the two time signals.
Is this possible? Do you have any suggestions how to achieve this?
Thank you very much in advance.
Fabio Freschi on 7 Sep 2021
Edited: Fabio Freschi on 7 Sep 2021
Use interp1 to resample your vector(s) in order to have the same length
clear variables, close all
% time vector
t1 = 0:1/1e3:2.5;
t2 = 0:1/1024:2.5;
% dummy vectors
Vector1 = sin(10*t1);
Vector2 = sin(10*t2)+sin(100*t2);
% resample vector 1
V1 = interp1(t1,Vector1,t2);
% or resample vector 2
V2 = interp1(t2,Vector2,t1);
% plot the difference
figure, hold on