Error using * in a simple matlab program

>> format short e
C=1;
O=0;
y=3;
m=1;
w=50;
t=0:1:10;
f=C.*exp(-(y.*t)/(2.*m))*cos(w.*t+O);
disp([t,f])
Error using *
Inner matrix dimensions must agree.

2 comentarios

Maxim Gaida
Maxim Gaida el 25 de Sept. de 2020
y=log(abs(x))*(x*cos(x)+log(abs(x)))
Error using *
Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To perform elementwise multiplication, use '.*
Maxim Gaida
Maxim Gaida el 25 de Sept. de 2020
need help

Iniciar sesión para comentar.

 Respuesta aceptada

Birdman
Birdman el 18 de En. de 2018
Editada: Birdman el 18 de En. de 2018
C=1;
O=0;
y=3;
m=1;
w=50;
t=0:1:10;
f=C.*exp(-(y.*t)./(2.*m)).*cos(w.*t+O);
Be careful that you should be doing element-wise multiplication while multipyling the exp term with cos term.

2 comentarios

Libby Goodes
Libby Goodes el 18 de En. de 2018
thank you! its worked now!
Can u show is the example of this equation because I'm having the same error.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Preguntada:

el 18 de En. de 2018

Comentada:

el 25 de Sept. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by