
Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Error in solving ode using symbolic calculations
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
hi, I am trying to compare my solution using ode45 and runge kutta to analytical solution of symbolic matlab.
Iam solving a simple system of linear ode equations: (this is the code)
syms s1(t) s2(t) I(t) u(t)
u(t) = 10; % input
% system of odes
ode1 = diff(s1) == u(t) - s1/55; % equation 1
ode2 = diff(s2) == s1/55 - s2/55; % equation 2
ode3 = diff(I) == s2/(0.12*55*60) - 0.138*I; % equation 3
odes = [ode1; ode2; ode3];
%initial conditions
cond1 = s1(0) == 0;
cond2 = s2(0) == 0;
cond3 = I(0) == 0;
conds = [cond1; cond2; cond3];
[s1Sol(t), s2Sol(t),Isol(t)] = dsolve(odes,conds)
I would like to see what Isol(t) is equal to. Every time I change the numbers at equation 2 or 3 it changes the solution of only equation 1! why????
I solved this analyticly on papper and its definetly wrong.
both ode45 and runge kutta gives me the same answer but for some reason analytical matlab solution is wrong.
Please help.
Thanks allot!!!
by the way this is ode45 function
% initial conditions are 0 0 0
% time interval 0 - 10
function dydt = odefun(t,y)
dydt = zeros(3,1);
dydt(1) = 10 - y(1)/55;
dydt(2) = y(1)/55 - y(2)/55;
dydt(3) = y(2)/(55*0.12*B60) - 0.138*y(3);
end
2 commentaires
Réponses (0)
Cette question est clôturée.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!