Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
How to solve a system of second order differential equation with initial conditions? Advice required!!!
조회 수: 1 (최근 30일)
이전 댓글 표시
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
David Goodmanson
2020년 12월 19일
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))
답변 (0개)
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!