Solve a second order differential equation system
显示 更早的评论
Hi,I am trying to solve a second order differential equation system which is :
diff(zf,2) == 9.81-(7.54)*diff(zf)+(7.54)*diff(zd)-(3942.4)*zf+(3942.4)*zd ; diff(zd,2) == 9.85 - (3.73)*diff(zd) +(3.73)*diff(zf) - (1.22)*diff(zd) +(3.73)*diff(za)-(1950.1)*zd +(1950.1)*zf-(519.5)*zf-(519.5)*zd+(519.5)*zf-(30960.8*zd)+(30960.8)*3.1; diff(za,2) == 9.81-(49.14)*diff(za)-(49.14)*diff(zd)+(49.14)*za-(49.14)*zd
All initial conditions are equal to zero. I tired. My ode cod did not work so i need help. Thank you
回答(1 个)
Star Strider
2017-12-14
Try this:
syms za(t) zf(t) zd(t) T Y
Eq1 = diff(zf,2) == 9.81-(7.54)*diff(zf)+(7.54)*diff(zd)-(3942.4)*zf+(3942.4)*zd ;
Eq2 = diff(zd,2) == 9.85 - (3.73)*diff(zd) +(3.73)*diff(zf) - (1.22)*diff(zd) +(3.73)*diff(za)-(1950.1)*zd +(1950.1)*zf-(519.5)*zf-(519.5)*zd+(519.5)*zf-(30960.8*zd)+(30960.8)*3.1;
Eq3 = diff(za,2) == 9.81-(49.14)*diff(za)-(49.14)*diff(zd)+(49.14)*za-(49.14)*zd;
[odesys, odesubs] = odeToVectorField(Eq1, Eq2, Eq3);
ode_fcn = matlabFunction(odesys, 'Vars',{T Y});
subcel = sym2cell(odesubs);
lgndstr = regexp(sprintf('%s\n', subcel{:}), '\n', 'split');
tspan = [0 2];
ic = zeros(size(odesubs));
[T,Y] = ode45(ode_fcn, tspan, ic);
figure(1)
plot(T, Y)
legend(lgndstr(1:end-1))
类别
在 帮助中心 和 File Exchange 中查找有关 Numerical Integration and Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!