Borrar filtros
Borrar filtros

plot error

3 visualizaciones (últimos 30 días)
hagai bar
hagai bar el 17 de Jun. de 2011
I am trying to do
t=0:0.001:10;
plot(0.25*exp(-t)*sin(2*t),t)
and it says:
??? Error using ==> mtimes
Inner matrix dimensions must agree.
When I tried to divide by exp(t) instead it gave me crap. any ideas? thanks

Respuesta aceptada

Sean de Wolski
Sean de Wolski el 17 de Jun. de 2011
t=0:0.001:10;
plot(0.25*exp(-t).*sin(2*t),t)
You want an element by element multiplication so you need the '.' in front of the '*'
  1 comentario
Arnaud Miege
Arnaud Miege el 17 de Jun. de 2011
You typed quicker than me :-)

Iniciar sesión para comentar.

Más respuestas (4)

Arnaud Miege
Arnaud Miege el 17 de Jun. de 2011
You need to use element-wise operating rather matrix opertaions. Read about Arithmetic Operators in the MATLAB documentation.
HTH,
Arnaud

Daniel Shub
Daniel Shub el 17 de Jun. de 2011
size(exp(-t))
size(sin(2*t))
You are trying to multiple a 1x1001 matrix with a 1x1001 matrix. The inner dimension (1001 and 1) do not match. Try .*
plot(0.25*exp(-t).*sin(2*t),t)

Anthony Smith
Anthony Smith el 17 de Jun. de 2011
Matlab is always thinking in terms of matrices. Therefore you would want to use element-by-element multiplication (.* instead of *) to generate your simple function in this case.
Try:
t=0:0.001:10; plot(t,0.25*exp(-t).*sin(2*t))

hagai bar
hagai bar el 17 de Jun. de 2011
thanks everyone

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by