How to plot a differential equation?

조회 수: 9 (최근 30일)
Sam
Sam 2017년 11월 6일
댓글: Steven Lord 2017년 11월 6일
Hello,
I've got the following differential equation: dN(t)/dt - ((k - (a*N(t)))*N(t)) = f(t) This is the logistic law of population growth. N(t) = #individuals. dN(t)/dt = the derivative of N(t) = change of # individuals = #individuals/s. k = velocity of growth = 1/s. a = an inhibition factor on the growth = 1/(#individual*s). f(t) = production function = #individual/s.
I want to plot this equation. How can I do this?
  댓글 수: 2
Torsten
Torsten 2017년 11월 6일
Do you want to plot the equation or the solution to the equation ?
Best wishes
Torsten.
Sam
Sam 2017년 11월 6일
The solution. So far I got this:
syms N(t);
ode = diff(N(t),t) == 2,309*N(t) - 2*N(t)^2;
cond = N(0) == 5;
NSol(t) = dsolve(ode, cond)
The solution is NSol(t) = 2*t + 5 I want to plot NSol by the command 'plot NSol' but it doesn't work...

댓글을 달려면 로그인하십시오.

답변 (1개)

Torsten
Torsten 2017년 11월 6일
편집: Torsten 2017년 11월 6일
ezplot(NSol,[0,4]);
Best wishes
Torsten.
  댓글 수: 3
Torsten
Torsten 2017년 11월 6일
ode = diff(N(t),t) == 2,309*N(t) - 2*N(t)^2;
I don't know what your ODE should look like, but the comma is wrong for certain.
Best wishes
Torsten.
Steven Lord
Steven Lord 2017년 11월 6일
Yes. The decimal separator in MATLAB is period (.) not comma (,), and to enter numbers in the thousands or greater omit the comma. The comma operator separates commands, elements in an array, or function input or output arguments.
Specify that coefficient as 2.309 or 2309 instead of 2,309.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by