How do at write the equation

조회 수: 1 (최근 30일)
Anna Nordin
Anna Nordin 2019년 9월 3일
댓글: Torsten 2019년 9월 3일
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.

채택된 답변

Torsten
Torsten 2019년 9월 3일
f = x.^2.*sin(x*pi)
  댓글 수: 2
Anna Nordin
Anna Nordin 2019년 9월 3일
Thank you!
I thought you only had to pun "." after the x
Torsten
Torsten 2019년 9월 3일
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개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by