Borrar filtros
Borrar filtros

why i'm getting this error?

1 visualización (últimos 30 días)
ocsse
ocsse el 25 de Mzo. de 2018
Editada: ocsse el 25 de Mzo. de 2018
why i'm getting this error: Error using * Inner matrix dimensions must agree.
thanks
  2 comentarios
David Fletcher
David Fletcher el 25 de Mzo. de 2018
Editada: David Fletcher el 25 de Mzo. de 2018
Sounds like you're trying to do inner matrix multiplication rather than element by element multiplication
possibly here: (a line number where the error occurred might be handy)
*an*cos*(2*pi*f0*n.'*t) + *bn*sin*(2*pi*f0*n.'*t
instead of
an.*cos(2*pi*f0*n.'*t) + bn.*sin(2*pi*f0*n.'*t
ocsse
ocsse el 25 de Mzo. de 2018
still getting an error

Iniciar sesión para comentar.

Respuesta aceptada

Star Strider
Star Strider el 25 de Mzo. de 2018
Your ‘an’ and ‘bn’ are (1x4) vectors, and ‘t’ is (1x500).
One way to avoid it is to transpose ‘an’ and ‘bn’ to column vectors:
s = s + a0 + an'*cos(2*pi*f0*n.'*t) + bn'*sin(2*pi*f0*n.'*t);
I do not know what you want for a final result. If you want a single row vector for each ‘n’, sum them:
s = s + a0 + sum(an'*cos(2*pi*f0*n.'*t) + bn'*sin(2*pi*f0*n.'*t));

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by