2nd order systems of differential equation

3 views (last 30 days)
  • d2y1/dt2+5*dy1/dt+y2^2-y1=0;
  • d2y2/dt2+5*dy2/dt+y3^2-y2=0;
  • d2y3/dt2+5*dy3/dt-y3=0;
I tried my level best, however i could not able to solve it. my errors are undefined function of x and double. running errors.
% code
function dydt=hi(t,y) %#ok<INUSL>
dydt=zeros(6,1);
n=3;
dydt(1:n) = y(n+1:2*n);
for i=n+1
dy(i)=x(i);
if i<2*n
dydt(i)=-5*x(i)-y(i+1)^2+y(i);
else
dydt(i)=-5*x(i)+y(i);
end
end
% code

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 17 Sep 2013
Edited: Azzi Abdelmalek on 17 Sep 2013
By adding 3 variables y4,y5 and y6 your system becomes a first order differential equations system.
%y4=dy1/dt, thus d2y1/dt2=dy4/dt
%y5=dy2/dt, thus d2y2/dt2=dy5/dt
%y6=dy3/dt, thus d2y3/dt2=dy6/dt
%The system of equation becomes
%dy1/dt=y11;
%dy2/dt=y22;
%dy3/dt=y33;
%dy4/dt+5*y4+y2^2-y1=0;
%dy5/dt+5*y5+y3^2-y2=0;
%dy6/dt+5*y6-y3=0;
% which can be programmed
function dy=myequ(t,y)
dy(1)=y(4)
dy(2)=y(5)
dy(3)=y(6)
dy(4)=-5*y4-y2^2+y1
dy(5)=-5*y5-y3^2+y2
dy(6)=-5*y6+y3
% you can call myequ
tspan=[0 10];
y0=[1 0 1 0 1 1]; % Initial conditions
[t,y]=ode45(@myequ,tspan,y0)
  1 Comment
lenin
lenin on 19 Sep 2013
Edited: lenin on 19 Sep 2013
Hi Azzi, thanks for your answer. i did take 'x' wrongly to use derivative of dydt. thansk for correcting me and that code is running. however, i am going to use below one due to i have if more than 3 equations.Thanks for your help.
% n=3;
% dy(1:n)=y(n+1:2*n);
% for i=n+1:2*n
% if i<2*n
% dy(i)=-5*y(i)-y(i-2)^2-y(i-3);
% else
% dy(i)=-5*y(i)-y(i-3);
% end
% end

Sign in to comment.

More Answers (1)

Susmita panda
Susmita panda on 6 Jun 2020
I have a differential equation of 2nd order: D2q(t)+ 2 zeta*w*Dq(t)+w^2*q(t)=2p(1+k)/(mL(1+8k/pi+2k^2))(sin(pi*v*t/L)+k) with initial conditions q(0) and Dq(t) = 0
I am getting a very lengthy solution. Is there any way to either simplify it or to confirm the differential equation from solution? Kindly suggest better way to solve such differential equation.
%code
syms q(t) zeta w P k m L v;
F0=2p(1+k)/(mL(1+8k/pi+2k^2))*(sin(pi*v*t/L)+k) ;
Dq=diff(q);
ode=diff(q,t,2)+2*zeta*Dq+w^2*q(t)==F0;
cond1=q(0)==0;
cond2=Dq(0)==0;
conds=[cond1 cond2];
ySol(t)=dsolve(ode,conds);
ySol=simplify(ySol)

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!