Академический Документы
Профессиональный Документы
Культура Документы
L.D.COLLEGE OF ENGINEERING
Matlab
(FOR SOLUTION OF DIFFERENTIAL EQUATION)
Guided by Prepared by
Prof. H.N.Pandya Maulik J. Patel-160280716012
Shyamesha A. Patel-160280716014
Differential Equations with 2
MATLAB
MATLAB has some powerful features for solving
differential equations of all types. We will explore
some of these features for the Constant
Coefficient Linear Ordinary Differential Equation
forms.
The approach here will be that of the Symbolic
Math Toolbox. The result will be the form of the
function and it may be readily plotted with
MATLAB.
Symbolic Differential 3
Equation
y Termsy
dy Dy
dt
2
d y
2 D2y
dt
n
d y
n Dny
dt
Finding Solutions to 4
Differential Equations
Solving a First Order Differential Equation
Solving a Second Order Differential
Equation
Solving Simultaneous Differential
Equations
Solving Nonlinear Differential Equations
Numerical Solution of a Differential
Equation
Solving a 1 st Order DE 5
dy
Consider the differential 2 y 12
equation: dt
Equation in Matlab
» syms y t
» ys=dsolve('Dy+2*y=12')
ys =6+exp(-2*t)*C1
y(0) 9 C1 3
» ys=dsolve('Dy+2*y=12','y(0)=9')
ys =
6+3*exp(-2*t)
Solving a 2 nd Order DE 8
» syms c y
» ys=dsolve('D2y = - c^2*y')
ys = C1*sin(c*t)+C2*cos (c*t)
dx dy
3x 4 y 4 x 3 y
dt dt
9
10
General Solution
Given the equations:
dx dy
3x 4 y 4 x 3 y
dt dt
» syms x y t
» [x,y]=dsolve('Dx=3*x+4*y','Dy=-4*x+3*y')
x = exp(3*t)*(cos(4*t)*C1+sin(4*t)*C2)
y = -exp(3*t)*(sin(4*t)*C1-cos(4*t)*C2)
12
Initial Conditions
Solve the previous system with the initial conditions:
x ( 0) 0 y ( 0) 1
» [x,y]=dsolve('Dx=3*x+4*y','Dy=-4*x+3*y',
'y(0)=1','x(0)=0')
x = exp(3*t)*sin(4*t) x e sin( 4t )
3t
y = exp(3*t)*cos(4*t) y e cos(4t )
3t
Non-Linear Differential Equation 13
Example
» syms y t
» y=dsolve('Dy=4-y^2','y(0)=1')
» y=simplify(y)
y=
y(t )
2 3e 4t 1
2*(3*exp(4*t)-1)/(1+3*exp(4*t))
1 3e 4t
Specifying the Independent 14
dy
Solve the differential equation: 2 y 12
dx
» y=dsolve('Dy+2*y=12','x')
y = 6+exp(-2*x)*C1 y( x) 6 C1e 2 x
15
Numerical Solution Example
Not all non-linear differential equations have a closed
form solution, but a numerical solution can be found
2
d y
Solve the differential equation:
2
9 sin( y) 0
dt
y ( 0) 1
Subject to initial conditions:
y (0) 0
16
Rewrite Differential Equation
2
d y d 2 y
2
9 sin( y) 0 2
y 9 sin( y )
dt dt
Rewrite in the
x1 y
following form x2 y x1
x1 (0) y(0) 1
x2 y 9 sin( y )
x2 9 sin( x1 ) x2 (0) y(0) 0
16
Solve DE with MATLAB 17
2
d y dy
2
3 2 y 24
dt dt
y (0) 10 y '(0) 0
'y(0)=10', 'Dy(0)=0')
y = 12+2*exp(-2*t)-4*exp(-t)
>> ezplot(y, [0 6])
17
18
Reference 19
http://www.mathworks.in/help/symbolic/simplify.h
tml
https://www.google.co.in/#q=laplace+transform
+using+matlab
20
Thank You