Graph not being displayed

1 Ansicht (letzte 30 Tage)
Ali Ahmed
Ali Ahmed am 6 Okt. 2022
Kommentiert: Ali Ahmed am 6 Okt. 2022
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.

Akzeptierte Antwort

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

Weitere Antworten (1)

the cyclist
the cyclist am 6 Okt. 2022
Bearbeitet: the cyclist am 6 Okt. 2022
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);

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by