![](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 次查看(过去 30 天)
显示 更早的评论
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 个评论
Darshan Ramakant Bhat
2017-5-8
Also, you are not using the variable 't' anywhere. Please provide the addition details on your question.
Guillaume
2017-5-8
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.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Directed Graphs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!