I wrote a very simple code:
x=linspace(-5,5,130);
y=((2.*x.^2)-(2.*x)-1)/((x.^4)+1);
plot(x,y);
This code doesnt display the graph, the coordinate plane is just empty. I cant figure out whats wrong with it.

 採用された回答

Torsten
Torsten 2022 年 10 月 6 日

0 投票

./ instead of simple / :
x=linspace(-5,5,130);
y=(2*x.^2-2*x-1)./(x.^4+1);
plot(x,y);

1 件のコメント

Ali Ahmed
Ali Ahmed 2022 年 10 月 6 日
Yes It worked, Thank You!

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

その他の回答 (1 件)

the cyclist
the cyclist 2022 年 10 月 6 日
編集済み: the cyclist 2022 年 10 月 6 日

1 投票

You missed a place where you need an element-wise operation. Try
x=linspace(-5,5,130);
y=((2.*x.^2)-(2.*x)-1)./((x.^4)+1); % You did not have ./, so y was not what you expected
plot(x,y);

カテゴリ

ヘルプ センター および File Exchange2-D and 3-D Plots についてさらに検索

質問済み:

2022 年 10 月 6 日

コメント済み:

2022 年 10 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by