How to compare two time signals with different amount of samples?

조회 수: 14 (최근 30일)
Maria Ma
Maria Ma 2021년 9월 7일
편집: Fabio Freschi 2021년 9월 7일
Hello,
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.
Best regards

답변 (1개)

Fabio Freschi
Fabio Freschi 2021년 9월 7일
편집: Fabio Freschi 2021년 9월 7일
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
plot(t2,Vector2-V1);
plot(t1,V2-Vector1);

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by