I am using the following commands to solve the ODE function "DynamicFunc":
x0_sim = zeros(12,1);
time_sim = [0 100];
options=odeset('AbsTol',1e-9,'RelTol',1e-6);
[tp,xp]=ode45(@DynamicFunc,time_sim,x0_sim,options);
The DynamicFunc can be any function and the code works very well.
the time of simulation is 0 - 100 seconds. the finals xp will have a size of 3017x12 (i.e. there are 12 states and 3017 trial points). If I want to run this code inside a FOR loop with duration of 1 second, something like this:
x0_sim = zeros(12,1);
time_sim = [0 1];
for tt = 1:100
options=odeset('AbsTol',1e-9,'RelTol',1e-6);
[tp,xp]=ode45(@DynamicFunc,time_sim,x0_sim,options);
x0_sim = xp(:,end);
end
The number of final iterations would be so different. How can I make them the same size (for both methods to have the final output with the same vector size)?
I guess the problem can be related to setting an specific option, but I couldn't find any.