can you please help me solve this diffetential equation system?

1 回表示 (過去 30 日間)
SOUGLES STAMATIS
SOUGLES STAMATIS 2021 年 4 月 7 日
コメント済み: Alan Stevens 2021 年 4 月 8 日
I need to solve a differential system and I coded in this way . I doesn't seem to work. I want to solve it only for t [0,4]. how can i do that?
syms x1(t) x2(t) x3(t) x4(t) x5(t) x6(t)
b=4.2030*10^5
m=1.0508*10^6
k=3.5025*10^9
A = [-2*b/(3*m) b/(3*m) 0 1/(3*m) -1/(3*m) 0 ;
b/(2*m) -2*b/(2*m) b/(2*m) 0 1/(3*m) -1/(3*m) ;
0 b/m -b/m 0 0 1/m ;
-k 0 0 0 0 0 ;
k -k 0 0 0 0 ;
0 k -k 0 0 0];
B = [-b/(3*m)*(1.8747*log(t)+8.6905);
0;
0;
-k*(1.8747*log(t)+8.6905);
0;
0;];
Y = [x1; x2; x3; x4; x5; x6];
odes = diff(Y) == A*Y + B
C = Y(0) == [0;0;0;0;0;0];
[x1Sol(t), x2Sol(t), x3Sol(t), x4Sol(t), x5Sol(t), x6Sol(t)] = dsolve(odes,C);
x1Sol(t) = simplify(x1Sol(t))
x2Sol(t) = simplify(x2Sol(t))
x3Sol(t) = simplify(x3Sol(t))
x4Sol(t) = simplify(x4Sol(t))
x5Sol(t) = simplify(x5Sol(t))
x6Sol(t) = simplify(x6Sol(t))

回答 (1 件)

Alan Stevens
Alan Stevens 2021 年 4 月 7 日
You have log(t) in the definition of B. This causes problems at t = 0.
  2 件のコメント
SOUGLES STAMATIS
SOUGLES STAMATIS 2021 年 4 月 7 日
okey, how can set the t value from 0.1 to 4?
Alan Stevens
Alan Stevens 2021 年 4 月 8 日
Like this
x0 = [0;0;0;0;0;0];
tspan = [0.01 4];
[t, x] = ode45(@bc, tspan, x0);
plot(t,x),grid
function xdot = bc(t,x)
b=4.2030*10^5;
m=1.0508*10^6;
k=3.5025*10^9;
A = [-2*b/(3*m) b/(3*m) 0 1/(3*m) -1/(3*m) 0 ;
b/(2*m) -2*b/(2*m) b/(2*m) 0 1/(3*m) -1/(3*m) ;
0 b/m -b/m 0 0 1/m ;
-k 0 0 0 0 0 ;
k -k 0 0 0 0 ;
0 k -k 0 0 0];
B = [-b/(3*m)*(1.8747*log(t)+8.6905);
0;
0;
-k*(1.8747*log(t)+8.6905);
0;
0;];
xdot = A*x + B;
end
You might need to plot the different x's on separate graphs to see them all properly.
Note that the results will be somewhat different depending on your starting value for t.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by