Matrix dimensions must agree
3 views (last 30 days)
Show older comments
Oscar Francisco Barba Toscano
on 23 Oct 2022
Commented: Oscar Francisco Barba Toscano
on 28 Oct 2022
¡Greetings to everyone!
I am trying to make a project of mixing an audio signal with an echoed white noise signal, but have the "Inner Matrix Dimensions Must Agree" at the moment of getting the transfer function.
I am gently asking for assistance.
Thank you all in advance.
The shown error is the following:
Error using / Matrix dimensions must agree.
Error in RuidoBlanco (line 24) H = eco_f/ruido_f;
And here is my code:
fs = 48000;
tSpan = 10;
t = 0:1/fs:tSpan-1/fs;
sam = size(t,2);
mu = 0;
sigma2 = 0.1;
dst = sqrt(sigma2);
var_dB = 10*log(sigma2);
X = dst*randn(sam,1)+mu;
ruido = int16(X/max(abs(X))*2^15-1);
archivo = 'RuidoBlanco.wav';
audiowrite(archivo, ruido, fs);
[ruidoeco, feco] = audioread('ruido_eco.wav');
[audio, faud] = audioread('audio.wav');
audio_f = abs(fft(audio));
ruido_f = abs(fft(ruido));
eco_f = abs(fft(ruidoeco));
H = eco_f/ruido_f;
audioeco = conv(H, audio_f);
audio_eco = ifft(audioeco);
audiofi = int16(audio_eco/max(abs(audio_eco))*2^15-1);
archivo = 'Final.wav';
audiowrite(archivo, audiofi, fs);
0 Comments
Accepted Answer
Walter Roberson
on 23 Oct 2022
The operator A/B is roughly A * pinv(B) where * is "inner product" (matrix multiplication). But / has more restrictions than that summary would suggest.
If you want to divide corresponding elements of two vectors or arrays then use the division operator which is ./ not /
More Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!