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

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);

 Accepted 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

More Answers (1)

dydt(1,6) is column 6 of row 1. You are creating a row vector of output values. The ode* routines require that the function creates a column vector, not a row vector.

Categories

Find more on Programming in Help Center and File Exchange

Products

Release

R2018b

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!