How to solve this two second order ODE with variable coefficients and change of coordinates afterwards?
3 次查看(过去 30 天)
显示 更早的评论
Hi, the problem here is to solve this 2 ode with variable coefficients and then change the coordinates using the called 'modal matrix'. This is a general vibration problem but given my little experience in matlab i don't know how to solve this equation and neither i know how to change the coordinates afterwards to represent grafically the solution. So the 2 equations are :
y'' + [-0.11674*(1-exp(-10*t))+0.05351*(1-cos(10t)]y'+y=0 y(0)=0 y'(0)=1.8989
y'' + [-0.18115*(1-exp(-10*t))+0.05157*(1-cos(10t)]y'+y=0 y(0)=0 y'(0)=0.6279
%the matrix for the change of coordintes is:
phi=[0.2029 0.9792;0.56535 -0.117145]
with the change of coordintes being x=phi*y with y and x being vector containing both solutions.
0 个评论
采纳的回答
Star Strider
2017-2-25
The symbolic derivation is similar to that in your previous Question. I list it here (commented-out) for reference.
Symbolic Derivation —
% syms p t y(t) Y
% p = sym('p%d', [1 2]);
% D1y = diff(y,t);
% D2y = diff(y,t,2);
% Eqn = D2y + p(1)*(1-exp(-10*t)) + p(2)*(1-cos(10*t))*D1y + y == 0;
% yode = odeToVectorField(Eqn);
% Yodefcn = matlabFunction(yode, 'Vars',[t Y p])
The code with the varying parameters is therefore straightforward with the results of the symbolic derivation.
The Code —
Yodefcn = @(t,Y,p1,p2) [Y(2);p1.*(exp(t.*-1.0e1)-1.0)-Y(1)+p2.*(cos(t.*1.0e1)-1.0).*Y(2)];
Pmat = [-0.11674 0.05351 1.8989; -0.18115 0.05157 0.6279]; % Parameter & Initial Condition Matrix
tspan = linspace(0, 15, 100);
for k1 = 1:size(Pmat,1)
Y0 = [0 Pmat(k1,3)];
[T{k1},Y{k1}] = ode45(@(t,Y) Yodefcn(t,Y,Pmat(k1,1),Pmat(k1,2)), tspan, Y0);
end
figure(1)
plot(T{1}, Y{1})
hold on
plot(T{2}, Y{2}, '--')
hold off
grid
xlabel('\itt\rm')
ylabel('\ity\rm(\itt\rm)')
The ‘p’ vector in the symbolic derivation are the relevant parameters. These are then entered into the ‘Pmat’ matrix for convenience, the first two columns corresponding to the first two parameters in each differential equation, and the third column the initial condition for the derivative. These are then called in the corresponding iterations of the for loop, and the results saved in the corresponding cell arrays, ‘T’ and ‘Y’. Then figure(1) plots them, the first set with a solid line, and the second set with a dashed line. (I would have added a legend if I knew what to call the plotted values.)
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!