Filter löschen
Filter löschen

How do I input this equation into Matlab to show me its graph?

1 Ansicht (letzte 30 Tage)
S
S am 5 Mai 2017
Kommentiert: Guillaume am 8 Mai 2017
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
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
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.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by