필터 지우기
필터 지우기

plot error

조회 수: 2 (최근 30일)
hagai bar
hagai bar 2011년 6월 17일
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

채택된 답변

Sean de Wolski
Sean de Wolski 2011년 6월 17일
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
Arnaud Miege
Arnaud Miege 2011년 6월 17일
You typed quicker than me :-)

댓글을 달려면 로그인하십시오.

추가 답변 (4개)

Arnaud Miege
Arnaud Miege 2011년 6월 17일
You need to use element-wise operating rather matrix opertaions. Read about Arithmetic Operators in the MATLAB documentation.
HTH,
Arnaud

Daniel Shub
Daniel Shub 2011년 6월 17일
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 2011년 6월 17일
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 2011년 6월 17일
thanks everyone

카테고리

Help CenterFile Exchange에서 Arithmetic Operations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by