Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Error in solving ode using symbolic calculations

3 ビュー (過去 30 日間)
Roman Gilgor
Roman Gilgor 2020 年 3 月 1 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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 件のコメント
darova
darova 2020 年 3 月 1 日
What is this?
Roman Gilgor
Roman Gilgor 2020 年 3 月 1 日
編集済み: Roman Gilgor 2020 年 3 月 1 日
Hi, avoid this ita my mistake in copying it from matlab. It just 0.12*60 Thanks!

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by