What is correct script for below question?

1 回表示 (過去 30 日間)
Manuj Sharma
Manuj Sharma 2020 年 2 月 13 日
回答済み: KALYAN ACHARJYA 2020 年 2 月 13 日
Use fplot to graph f(x) over x from -pi to pi .
Do i need to mention the value of x as well or not?
if yes then x=[0,1,pi/2,pi]
Script:
f=@(x) x.^2-sin(x)+(1./x);
x=[0,1,pi/2,pi];
fplot(f(x),[-pi,pi])
then
is this correct?
  1 件のコメント
Temu Gautama
Temu Gautama 2020 年 2 月 13 日
fplot( f, [-pi pi] )

サインインしてコメントする。

回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2020 年 2 月 13 日
here fplot x ranges -pi to pi
f=@(x) x.^2-sin(x)+(1/x);
fplot(f,[-pi pi]);
Now get the f value with x_data=x=[0,1,pi/2,pi], hopfully you may get inf,1.1585, 2.1040, 10.1879
With fixed value of x, you definitely get constant (straight line)

カテゴリ

Help Center および File ExchangeDirected Graphs についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by