user1936752
user1936752

Reputation: 858

ode45 with short timesteps not working

I am using ode45 and I can't figure out what to do in this case. I have a differential equation where my paramters change very quickly with time. Ideally, I would like to choose tspan to be like 0:epsilon:10*epsilon where epsilon is of an appropriately small order considering whatever I have in the factors of my DE. However, this does not work and MATLAB simply gives me a plot where nothing changes from my initial conditions.

I did the obvious thing to fix it which was the following. Say I have xdot(t)=10^9*x(t). I rewrite it as xdot(t)=x(t) and label my time axis as nanoseconds instead of seconds.

Just curious if MATLAB can do this on its own.

Upvotes: 1

Views: 401

Answers (1)

Pursuit
Pursuit

Reputation: 12345

You can set a maximum time step using ODE options.

opt = odeset('MaxStep',epsilon)
[t,y] = ode45(odeFun,tSpan,y0,opt)

To get an idea of all the options that you can change when customizing an ODE solver look at docsearch odeset.

Upvotes: 1

Related Questions