this is the code ( want to plot graph of nonlinear ode)
syms S E I R N a b c d e g h j;a=0.01;b=0.25;c=0.1;d=0.2;e=0.2;N=520;j=0.167;g=0.8;h=0.02;f=@(t,y)[((b*N)-(g*y(1))-(j*y(1))-((a*y(1)*y(3))/N)-d*y(1));(j*y*(1)+((a*y(1)*y(3))/N)-(c*y(2))-(d*y(2)));((c*y(2))-(d*y(3))-(h*y(3))-(e*y(3)));((g*y(1))+(e*y(3))-(d*y(4)))];tspan=[0,100];xinit=[300 100 75 45];figure(1)xlabel('time(years)')ylabel('population')ode45(f,tspan,xinit)legend('S','E','I','R')
this is the error
Error using odearguments (line 95)@(T,Y)[((B*N)-(G*Y(1))-(J*Y(1))-((A*Y(1)*Y(3))/N)-D*Y(1));(J*Y*(1)+((A*Y(1)*Y(3))/N)-(C*Y(2))-(D*Y(2)));((C*Y(2))-(D*Y(3))-(H*Y(3))-(E*Y(3)));((G*Y(1))+(E*Y(3))-(D*Y(4)))] returns avector of length 7, but the length of initial conditions vector is 4. The vector returned by@(T,Y)[((B*N)-(G*Y(1))-(J*Y(1))-((A*Y(1)*Y(3))/N)-D*Y(1));(J*Y*(1)+((A*Y(1)*Y(3))/N)-(C*Y(2))-(D*Y(2)));((C*Y(2))-(D*Y(3))-(H*Y(3))-(E*Y(3)));((G*Y(1))+(E*Y(3))-(D*Y(4)))] and theinitial conditions vector must have the same number of elements.Error in ode45 (line 115) odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);Error in ttvmd (line 9)ode45(f,tspan,xinit)
Please help me…….
Best Answer