can you please help me solve this diffetential equation system?
显示 更早的评论
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
2021-4-7
1 个投票
You have log(t) in the definition of B. This causes problems at t = 0.
2 个评论
SOUGLES STAMATIS
2021-4-7
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Modeling 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!