signals addition

Illustration
Abdulzahra786 - 2021-02-09T11:02:15+00:00
Question: signals addition

Hi, I have the following code. x1=wavread('speech.wav'); x2=wavread('speech_noise.wav'); I have to do x2-x1 I am getting the error as Dimension mismatch. How to rectify it?

Expert Answer

Profile picture of John Williams John Williams answered . 2025-11-20

Assuming they correspond to the same sampling rates, truncate one of them to be of the same length as the smaller one:
 
 
n1 = length(x1);
n2 = length(x2);

% Assuming n1 < n2
x2 = x2(1:n1)

Or maybe you want to interpolate

x2 = interp1(1:n2, x2, linspace(1, n2, n1));


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!