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 Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by