MATLAB: Error using odearguments (line 93) PHASE_1 must return a column vector.

MATLABode45

Here is my call to ode45
[t,y] = ode45(@Phase_1, tspan, intial_conditions);
and here is the function i am referencing
function dydt = Phase_1(t, y)
dydt(1,1) = y(3);
dydt(1,2) = y(4);
dydt(1,3) = 2*t;
dydt(1,4) = 1.5*t;
dydt(1,5) = t^(1/9);
dydt(1,6) = t^(1/6);
end
when I call ode45 I get these error messages and I can't seem to figure out what I'm doing wrong. Any help would be much appreciated.
Error using odearguments (line 93)
PHASE_1 must return a column vector.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in rocket_code (line 32)
[t,y] = ode45(@Phase_1, tspan, intial_conditions);

Best Answer

You have the indices reversed.
Try this:
function dydt = Phase_1(t, y)
dydt(1,1) = y(3);
dydt(2,1) = y(4);
dydt(3,1) = 2*t;
dydt(4,1) = 1.5*t;
dydt(5,1) = t^(1/9);
dydt(6,1) = t^(1/6);
end
Related Question