MATLAB Answers

How do at write the equation

조회 수: 1(최근 30일)
Anna Nordin
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

댓글을 달려면 로그인하십시오.

채택된 답변

Torsten
Torsten 3 Sep 2019
f = x.^2.*sin(x*pi)

  댓글 수: 2

Anna Nordin
Anna Nordin 3 Sep 2019
Thank you!
I thought you only had to pun "." after the x
Torsten
Torsten 3 Sep 2019
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 ".*" .

댓글을 달려면 로그인하십시오.

추가 답변(0개)


Translated by