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일

0 개 추천

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개)

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

질문:

2019년 9월 3일

댓글:

2019년 9월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by