MATLAB: While running this code i am unable to get y (1) ,y(2) and y(3)values.y(1) is coming similar to value of indepent variable and y(2),y(3) is coming 1 &0 resp.Plz. guide where am i getting wrong. thnx

ode45

function dydt = ode5(t,y) dydt = zeros(3,1); % a column vector dydt(1) = y(2); dydt(2) = y(3); dydt(3) = (-3.06091)*((y(2)^2)+(y(1)*y(3)))*(y(3)^0.67); end
options = odeset('RelTol',1e-6,'AbsTol',[1e-6 2e-6 3e-6]); [t,y] = ode45(@ode5,[0 10],[0 1 0],options); plot(t,y(:,1),'-',t,y(:,2),'-.',t,y(:,3),'.')

Best Answer

Nita, your code is good, the output from MATLAB is correct.
Looking at your DE
dydt(1) = y(2);
dydt(2) = y(3);
dydt(3) = (-3.06091)*((y(2)^2)+(y(1)*y(3)))*(y(3)^0.67);
the derivatives at t = 0 are
dydt(1) = 1
dydt(2) = 0
dydt(3) = 0
which means that y(1) is increasing, y(2) and y(3) remain constant, y(2) = 1, y(3) = 0. At the next time step, t = dt, you get the same derivatives, which you therefore get for all t. As a result, y(1) is increasing linearly with a slope of 1, whereas y(2) and y(3) remain constant. You will get a different result for different intial conditions.