Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with a simple system of ODE

Status
Not open for further replies.

Freidenker

Industrial
Oct 11, 2007
1
Hello,

I have a simple system of ODE;

function xdot=test(t,x);

xdot=[
2*x(1)*(1-x(1)/2000)-(15*x(1)*x(2))/(x(1)+70);
1*x(2)*((15*x(1))/(x(1)+70)-9)];

return;

tspan=[0 50]; x0=[1000;20];
options=odeset('RelTol',0.01);

[t,x]=ode23('test',tspan,x0,options);

plot(t,x, '-')

xlabel('time');
ylabel('size');

As you can see, the RelTol is very high, still, I can't plot this, it says "busy" and it waits, waits, waits... nothing happens. I really can't understand, it's a simple system !

BTW, how can I put all the programs in a single m file ?

Thank you,
 
Replies continue below

Recommended for you

You're only putting in two time points, 0 and 50. Change the tspan line to tspan=linspace(0,50,10000); x0=[1000;20]; and try it again.

Also, the way the ODE solvers work is you put the ODE equation in a separate m-file function, then call that function. I don't know how to put everything in the same file; maybe someone else knows.

xnuke
"Live and act within the limit of your knowledge and keep expanding it to the limit of your life." Ayn Rand, Atlas Shrugged.
Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor