Cannot make vektor of exp(x)/(exp(x) 1)

2 Ansichten (letzte 30 Tage)
Christian Christiansen
Christian Christiansen am 13 Okt. 2019
Beantwortet: Ekemini Stephen am 13 Okt. 2019
I am trying to make a plot of the funktion f(x)=exp(x)/(exp(x)+1)
This is how I tried to do it:
x = [0:0.1:2];
y1 = exp(x)/(exp(x)+1);
plot(x, y1)
But for some reason I only get one value in y1.
I have tried changing the the funtion to something else, and it works fine.
I have tried to see if I wrote the function wrong by simply checking different numbers between 0 and 2 and it works fine.
  2 Kommentare
dpb
dpb am 13 Okt. 2019
Look up the "dot" operators for element-by-element operation instead of matrix operations...
"./" insread of "/"
Christian Christiansen
Christian Christiansen am 13 Okt. 2019
This solved it thank you :)

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Ekemini Stephen
Ekemini Stephen am 13 Okt. 2019
Hi, check this code out, its the correct code.
%% YOUR CORRECT CODE
x = 0:0.1:2;
y1 = exp(x)./(exp(x)+1);
figure
plot(x,y1,'r--o','LineWidth',2)

Weitere Antworten (0)

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by