Hello,
I don't understand why I am getting the following error:
Error using odearguments (line 87)The entries in tspan must strictly increase or decrease.Error in ode15s (line 150) odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);Error in trajecttest (line 39) [T,S] = ode15s(@bdipuniodefun, tspan, icv);
For this for loop:
spart = [0.05 0.05 0.];vpart = [-1.7585E+7 -1.7585E+7 0.];tstep = 1E-7; %Defining time step
tfin = 1.1E-6; %Defining final time
intspan = [0:tstep:tfin]; %Total time span
[introw,intcol] = size(intspan);W = zeros((3*intcol),6); %Generates matrix of zeros that the trajectory solver will populate later
for t = 0:1:intcol/2-1 x = spart(1); y = spart(2); z = spart(3); vx = vpart(1); vy = vpart(2); vz = vpart(3); icv = [x; y; z; vx; vy; vz]; %Time span
tspan = [intspan(2*t+1) intspan(2*t+2)/2 intspan(2*t+2)]; [T,S] = ode15s(@bdipuniodefun, tspan, icv); [rownum,colnum] = size(S); W((1+3*t):(3+3*t),(1:6)) = S; vparts(1) = S(rownum,4); vparts(2) = S(rownum,5); vparts(3) = S(rownum,6); sparts(1) = S(rownum,1); sparts(2) = S(rownum,2); sparts(3) = S(rownum,3); end
The ODE solver accepts the inputs if there is no for loop invovled like this:
x = 0.05;y = 0.05;z = 0.;vx = -1.7585E+7;vy = -1.7585E+7;vz = 0.;tstep = 0.5E-8; %Defining time steptfin = 1E-8; %Defining final timeintspan = [0:tstep:tfin]; %Total time span[introw,intcol] = size(intspan);icv = [x; y; z; vx; vy; vz]; %Format: [x; y; z; vz; vy; vz]
%Time Span (sec)
tspan = [intspan];[T,W] = ode15s(@bdipuniodefun, tspan, icv);[rownum,colnum] = size(W);
So why is it that adding the for loop causes this error? I know that the numbers that the "tspan" array is taking in are exactly the same since I tested it in the command window.
Best Answer