MATLAB Answers

0

How do at write the equation

Anna Nordin 님이 질문을 제출함. 3 Sep 2019
최근 활동 Torsten 님이 댓글을 추가함. 3 Sep 2019
How do I make this equation work for a vector? (the vector x=[-1:0.1:1])
f = x 2 sin(πx)
I've tried the following:
f=x.^2*sin(x.*pi)
f=x.^2*sin(x*pi)
It doesn't work.

  댓글 수: 0

로그인 to comment.

답변 수: 1

Torsten 님의 답변 3 Sep 2019
 채택된 답변

f = x.^2.*sin(x*pi)

  댓글 수: 2

Thank you!
I thought you only had to pun "." after the x
No. As soon as you multiply vectors elementwise, you have to use the ".*", "./", ".^" operators.
x.^2 is a vector, sin(pi*x) is a vector. To multiply them elementwise, you have to use ".*" .

로그인 to comment.



Translated by