Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
S
S el 5 de Mayo de 2017
Comentada: Guillaume el 8 de Mayo de 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 comentarios
Darshan Ramakant Bhat
Darshan Ramakant Bhat el 8 de Mayo de 2017
Also, you are not using the variable 't' anywhere. Please provide the addition details on your question.
Guillaume
Guillaume el 8 de Mayo de 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.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Directed Graphs en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by