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에 대해 자세히 알아보기

질문:

2012년 2월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by