필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
S
S 2017년 5월 5일
댓글: Guillaume 2017년 5월 8일
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
Darshan Ramakant Bhat 2017년 5월 8일
Also, you are not using the variable 't' anywhere. Please provide the addition details on your question.
Guillaume
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 CenterFile Exchange에서 Directed Graphs에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by