I try to plot on [1000, 5000] the solution of the system of ODEs
with the initial conditions , where and .
I used the function
function dzdt=odefunw1(t,z)f=1/(t+1);g=1+exp(-t);h=diff(f);dzdt=zeros(2,1);dzdt(1)=z(2)-f*z(1);dzdt(2)=(g+h)*z(1)-f*z(2);end
and the commands
tspan = [1000 5000];z0 = [0.001 0.001];[t,z] = ode45(@(t,z) odefunw1(t,z), tspan, z0);plot(t,z(:,1),'r')
The following errors occured:
In an assignment A(:) = B, the number of elements in A and B must be the same.Error in odefunw1 (line 7)dzdt(2)=(g+h)*z(1)-f*z(2);Error in @(t,z)odefunw1(t,z)Error in odearguments (line 90)f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115) odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
How could I fix it ? Many thanks in advance.
Best Answer