Info
This question is closed. Reopen it to edit or answer.
How to solve a system of second order differential equation with initial conditions? Advice required!!!
1 view (last 30 days)
Show older comments
Hi I want to solve this equation showed in the screenshot. I have got it to solve the general solution however when I input the initial conditions it does not work. I am getting a vicious error, please provide solution to how to solve this?!?!?
This is my code so far:
clear
syms x1(t) x2(t)
% define the equations
Dx1 = diff(x1,t);
Dx2= diff(x2,t);
ode1 = diff(x1,t,2) == 0*x1 + x2;
ode2 = diff(x2,t,2) == -2*x1-3*x2;
odes = [ode1;ode2;]
[x1Sol(t), x2Sol(t)] = dsolve(odes)% solve the equation with c included
% define conditions, solve for perticular solution
cond1 = x1(0) == 1;
cond2 = x2(0) == -1;
cond3 = Dx1(0) == 1;
cond4 = Dx2(0)==0;
conds = [cond1 cond2 cond3 cond4];
[x1Sol(t), x2Sol(t)] = dsolve(odes,conds)
PS. In this screenshot it says Matlab R2017a however, I also have the latest R2020b installed. I just forgot to delete the old one.
2 Comments
David Goodmanson
on 19 Dec 2020
Hi AS,
the code ran with no problem in 2019b, with the following results:
% odes(t) =
% diff(x1(t), t, t) == x2(t)
% diff(x2(t), t, t) == - 2*x1(t) - 3*x2(t)
%
%
% x1Sol(t) = - C2*cos(t) - C1*sin(t)
% - (2^(1/2)*C4*cos(2^(1/2)*t))/4 - (2^(1/2)*C3*sin(2^(1/2)*t))/4
%
% x2Sol(t) = C2*cos(t) + C1*sin(t)
% + (2^(1/2)*C4*cos(2^(1/2)*t))/2 + (2^(1/2)*C3*sin(2^(1/2)*t))/2
%
% x1Sol(t) = 5^(1/2)*cos(t - atan(2)) - (2^(1/2)*sin(2^(1/2)*t))/2
%
% x2Sol(t) = 2^(1/2)*sin(2^(1/2)*t) - 5^(1/2)*cos(t - atan(2))
Answers (0)
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!