×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Problems with a simple system of ODE

Problems with a simple system of ODE

Problems with a simple system of ODE

(OP)
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,

RE: Problems with a simple system of ODE

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: Eng-Tips.com Forum Policies for tips on how to make the best use of Eng-Tips.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources