I'm trying to solve the following differential equation
where I have and ,3×1 vectors, as intital conditions.
Here is my code:
clear allclcmu = 400000; %km^3/s^2r0 = [9000;1400;800];%kmv0 = [-1.3;6.3;3.7];%km/stspan = [0;30000];ic = [r0;v0];f = @(t,y)[y(2);-(mu*y(1))/(norm(y(1))^3)];[ts,ys] = ode45(f,tspan,ic);
I'm getting the error of:
@(T,Y)[Y(2);-(MU*Y(1))/(NORM(Y(1))^3)] returns a vector of length 2, but the length of initial conditions vector is 6. Thevector returned by @(T,Y)[Y(2);-(MU*Y(1))/(NORM(Y(1))^3)] and the initial conditions vector must have the same number ofelements.Error in ode45 (line 115)odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);Error in orbitplot (line 24)[ts,ys] = ode45(f,tspan,ic);
How am I able to set up ode45 to be able to accept vectors as initial conditions?