First I did the variable sustition as follow:
x=x(1)
x'=x(2)
x''=-x(1)-x(4)-3*x(2)^2+x(5)^3+6*x(6)^2+2*t
y=x(4)
y'=x(5)
y''=x(6)
y'''=-x(6)-x(2)-exp(-x(1))-t
The code is:
ecu1=@(t,x)[x(2);-x(1)-x(4)-3*x(2)^2+x(5)^3+6*x(6)^2+2*t;x(4);x(5);x(6);-x(6)-x(2)-exp(-x(1))-t]rvt=0:0.001:5;ci=[2 -4 -2 7 6];[t,x]=ode45(ecu1,rvt,ci)plot(t,x)
Index exceeds array bounds.
Error in Estudio1>@(t,x)[x(2);-x(1)-x(4)-3*x(2)^2+x(5)^3+6*x(6)^2+2*t;x(4);x(5);x(6);-x(6)-x(2)-exp(-x(1))-t]
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Thanks for your help
Best Answer