![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/184336/image.png)
How do I input this equation into Matlab to show me its graph?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I am having trouble creating a line graph for the following equation: y = rx(1-x/K) - hx/(1+0.05x) where r=0.5, K=100, h=0.8 How can I correctly code this equation into Matlab to show me the graph.
I have used Wolfram to get a general idea of what the graph is supposed to look like, however when I input into Matlab I am getting a hyperbola, which is not right.
function y = example(t, x)
r=0.5;
K=100;
h=0.8;
y = (r.*x.*((1-x)/K)) - ((h.*x)./(1+0.05.*x))
end
In my command window I put in
t=0;
x=[-0.2:0.1:1.2];
example(t,x)
plot(x,y)
3 Kommentare
Darshan Ramakant Bhat
am 8 Mai 2017
Also, you are not using the variable 't' anywhere. Please provide the addition details on your question.
Guillaume
am 8 Mai 2017
As already said, t is not used in example so I suspect there is a major error in the code.
As it is, one obvious singularity point is when the denominator is zero, which will obviously happen at x = -20. So plotting the function between -0.2 and 1.2 does not make much sense. Finding the zeros of the cubic polynomial in the numerator would also help.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Directed Graphs 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!