how to plot a semi-stable solution to autonomous DE

1 view (last 30 days)
I have been trying to plot this and am only able to do so for certain initial values of y (y(0)) and can't see why this is the case.
Can anyone tell me how to do this for all values of y(0)?
the equation is: dy/dt =k(1-y)^2.
First, I made an Mfile function for the RHS of this:
>>function ydot=semi(t,y) >>k=2 >>ydot=k*((1-y)^2)
Then, in the command window: >>tspan=[0 20]; >>y0=2; >>[t,y]=ode45('semi',tspan,yo); >>plot(t,y)
As I say, this seems to have worked for values of y_0<1 but when y_0>1, there is an error message reading:
Warning: Failure at t=4.999822e-01. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (8.881784e-16) at time t. > In ode45 at 309

Accepted Answer

Mischa Kim
Mischa Kim on 10 Mar 2014
Edited: Mischa Kim on 10 Mar 2014
Will, the problem is that the system is unstable for y0 > 1. E.g., for y0 = 2 the derivative
dy/dt = k(1 - y)^2
at t = 0 is dy/dt(0) = 2
is positive and remains positive for all t, therefore y is increasing without bounds. To show (plot) an unstable solution you could decrease the simuation time and initial condition to say
tspan = [0 2];
y0 = 1.1;
All other stable and neutrally stable solutions you can plot without any problems.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!