Error using ==> times Matrix dimensions must agree
15 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I currently doing a audio compression project I am having some issues regarding my matrix. Getting an error Error using ==> times Matrix dimensions must agree
[b,R] = wavread ('transparent-build-up.wav');
N = length(b);
c = dct(b); % Compute the interpolation model coefficients
w = sqrt(2/N);
f = linspace(0,R/2,N)';
plot (f,w*c); % Shows a plot of the frequencies coefficients for the sample
% Generate a mask of zeros and ones. m is 0 for every frequency above 3000, 1 otherwise.
% This mask will cut-off all frequencies above 3000 cycles/second.
m = (f<3000);
plot (f,(w*m.*c)); % Display the filtered frequency coefficients.
%y = idct(m.*c); % Generate a filtered sound sample data set
sound(y,R); % Listen to the result
1 comentario
Rik
el 19 de Oct. de 2017
What are the sizes involved for (w*m.*c)? c might not be 1xN or Nx1.
Next time, make sure to copy the entire error message. That will make it much easier to debug. That's the whole point of having a verbose error message.
Respuestas (1)
Cam Salzberger
el 19 de Oct. de 2017
Hello Sumiran,
Rik's on the right track. I'm fairly certain that wavread will give you a row vector (1xN) for the first output ("b"), which will then cause "c" to have that same size. "w" is a scalar, so w*m will have the size of "m", which is a column vector due to the transpose in the definition for "f". (Nx1).*(1xN) will result in that error, so you probably want to skip the transpose, or transpose b when you first get it.
Also, it may help readability if your variables had meaningful names.
Hope this helps!
-Cam
0 comentarios
Ver también
Categorías
Más información sobre Digital Filter Design en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!