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

 采纳的回答

You need to use .*
y = exp(2*sin(0.4*x))*5 .* cos(4*x);

2 个评论

thank you! I was putting after the exp().
Why does it need to be after the 5?
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 Exchange 中查找有关 Spline Postprocessing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by