plot error
1 回表示 (過去 30 日間)
古いコメントを表示
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
0 件のコメント
採用された回答
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 '*'
その他の回答 (4 件)
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
0 件のコメント
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)
0 件のコメント
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))
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Arithmetic Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!