Receiving mtimes error for passing vector through a function and I don't know why. Help?

 採用された回答

Honglei Chen
Honglei Chen 2012 年 2 月 15 日
You need to use .*
y = exp(2*sin(0.4*x))*5 .* cos(4*x);

2 件のコメント

Victor
Victor 2012 年 2 月 15 日
thank you! I was putting after the exp().
Why does it need to be after the 5?
Honglei Chen
Honglei Chen 2012 年 2 月 15 日
You can think of anything before 5 is a row vector and then everything after 5 is another row vector. To multiply two vectors together, you need the .* there. If you put it in front of 5, since at that time MATLAB is evaluating a multiplication between a vector and a scalar, it doesn't help. Once it finishes 5, it still encounter the same situation. If you have to put it in front of 5, then you need to group 5 and cos(4*x) together with a parenthesis.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeSpline Postprocessing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by