signals addition

A
Abdulzahra786 · Feb 9, 2021 · 1.9K views
Question
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 PhD Expert
Answered Aug 25, 2026
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));
100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!