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

2 views (last 30 days)
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),'.')

Accepted Answer

Mischa Kim
Mischa Kim on 13 Mar 2014
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.
  8 Comments
Mischa Kim
Mischa Kim on 14 Mar 2014
Yep. Both t and y(1) have the same initial values and increase with the same slope (= derivative) of 1.

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!