Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

How to solve a system of second order differential equation with initial conditions? Advice required!!!

1 vue (au cours des 30 derniers jours)
EE_student
EE_student le 19 Déc 2020
Clôturé : EE_student le 20 Déc 2020
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 commentaires
David Goodmanson
David Goodmanson le 19 Déc 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))
EE_student
EE_student le 19 Déc 2020
Modifié(e) : EE_student le 19 Déc 2020
Hi David,
Thank you for helping me. I tried the code in the R2020b version and it works pretty well. I will defo delete this older version. What a waste of time, I've wasted a whole today on this.
This questions is solved.

Réponses (0)

Cette question est clôturée.

Produits


Version

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by