How many iterations does a ODE solver like ode45 do? What do the dimension of outputs mean?
Show older comments
Say I have a state space function
function dx = sys(t, x)
A = [0 1; -2 3]; B = [0;1]; K = [-1 -1];
u = K*x;
dx = A*x + B*u;
end
Which I will call with the following script:
tspan = [0 10];
iniCon = [1;-1]
[t, x] = ode45(@sys, tspan, iniCon);
plot(t,x)
This way, I have a two-variable function of x with an initial condition of [1;-1] which I want plotted over 0 to 10 time units.
When running this program, I get t and x with dimension 85x1 and 85x2, respectively.
My questions which are made explicit in its subquestions related to this example are:
1) Why do I get 85 rows in x?
1a)- Where is the number 85 coming from?
1b)- Why are rows and columns reverted? x started with 2 columns, now it is 2 rows.
2) How many iterations does ode45 do and why this amount?
2a) Similarly to (1a): From a timespan of [1 10] I get 85 timestamps, what is the relation and why?
Thanks in advance. See a plot below of plot(t,x).

Accepted Answer
More Answers (0)
Categories
Find more on Ordinary Differential Equations 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!