Download presentation

Presentation is loading. Please wait.

Published byKasey Calverley Modified over 2 years ago

2
Differential Equations Math Review with Matlab: Finding Solutions to Differential Equations S. Awad, Ph.D. M. Corless, M.S.E.E. D. Cinpinski E.C.E. Department University of Michigan-Dearborn

3
Differential Equations:Finding Solutions to DEs 2 Finding Solutions to Differential Equations n Solving a First Order Differential Equation Solving a First Order Differential Equation n Solving a Second Order Differential Equation Solving a Second Order Differential Equation n Solving Simultaneous Differential Equations Solving Simultaneous Differential Equations n Solving Nonlinear Differential Equations Solving Nonlinear Differential Equations n Numerical Solution of a Differential Equation Numerical Solution of a Differential Equation n Using the ODE45 Solver Using the ODE45 Solver

4
Differential Equations:Finding Solutions to DEs 3 n Consider the differential equation: Solving a 1 st Order DE n The general solution is given by: The Matlab command used to solve differential equations is dsolve Verify the solution using dsolve command

5
Differential Equations:Finding Solutions to DEs 4 Solving a Differential Equation in Matlab n C1 is a constant which is specified by way of the initial condition n Dy means dy/dt and D 2 y means d 2 y/dt 2 etc » syms y t » ys=dsolve('Dy+2*y=12') ys = 6+exp(-2*t)*C1

6
Differential Equations:Finding Solutions to DEs 5 n Verify results given y(0) = 9 Verify Results » ys=dsolve('Dy+2*y=12','y(0)=9') ys = 6+3*exp(-2*t)

7
Differential Equations:Finding Solutions to DEs 6 n Find the general solution of: Solving a 2 nd Order DE » syms c y » ys=dsolve('D2y=-c^2*y') ys = C1*sin(c*t)+C2*cos(c*t)

8
Differential Equations:Finding Solutions to DEs 7 n Solve the following set of differential equations: Solving Simultaneous Differential Equations Example n Syntax for solving simultaneous differential equations is: dsolve( ' equ1 ', ' equ2 ',…)

9
Differential Equations:Finding Solutions to DEs 8 n The general solution is given by: General Solution n Given the equations:

10
Differential Equations:Finding Solutions to DEs 9 Matlab Verification » 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) n Given the equations: n General solution is:

11
Differential Equations:Finding Solutions to DEs 10 n Solve the previous system with the initial conditions: Initial Conditions » [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) y = exp(3*t)*cos(4*t)

12
Differential Equations:Finding Solutions to DEs 11 Non-Linear Differential Equation Example n Solve the differential equation: n Subject to initial condition: » syms y t » y=dsolve('Dy=4-y^2','y(0)=1') » y=simplify(y) y = 2*(3*exp(4*t)-1)/(1+3*exp(4*t))

13
Differential Equations:Finding Solutions to DEs 12 If another independent variable, other than t, is used, it must be introduced in the dsolve command Specifying the Independent Parameter of a Differential Equation » y=dsolve('Dy+2*y=12','x') y = 6+exp(-2*x)*C1 n Solve the differential equation:

14
Differential Equations:Finding Solutions to DEs 13 Numerical Solution Example n Not all non-linear differential equations have a closed form solution, but a numerical solution can be found n No closed form solution exists Use the ode45 command to get a numerical solution n Solve the differential equation: n Subject to initial conditions:

15
Differential Equations:Finding Solutions to DEs 14 Rewrite Differential Equation n Rewrite in the following form

16
Differential Equations:Finding Solutions to DEs 15 Create a Matlab function evalxdot to evaluate Create a New Function andnumerically in terms of x 1 and x 2. function xdot=evalxdot(t,x) %x=[x1, x2] %xdot=[dx1/dt, dx2/dt]; xdot=[x(2); -9*sin(x(1))];

17
Differential Equations:Finding Solutions to DEs 16 ODE45 n ODE45 is used to solve non-stiff differential equations [T,Y] = ODE45('F',TSPAN,Y0 ) T = Time vector Y = Output corresponding to time vector F = Function name TSPAN = Simulation duration Y0 = Initial conditions If the left hand side [T,Y] of the output arguments is omitted, Matlab solves it and plots it

18
Differential Equations:Finding Solutions to DEs 17 Returning t, y and dy/dt n Run the solver with the input and output arguments specified » [t,y]=ode45('evalxdot',10,[1 0]); » plot(t,y) » xlabel('Time (sec)'); » ylabel('Amplitude'); » title('Numerical Solution'); » legend('Y','dY/dt')

19
Differential Equations:Finding Solutions to DEs 18 Plot of Solution

20
Differential Equations:Finding Solutions to DEs 19 Omit Output Arguments n We can run the solver again without output arguments n Omitting the output arguments causes Matlab to plot the results » ode45('evalxdot',10,[1 0]); » xlabel('Time (sec)'); » ylabel('Amplitude'); » title('Numerical Solution'); » legend('Y','dY/dt')

21
Differential Equations:Finding Solutions to DEs 20 Plot of Results

22
Differential Equations:Finding Solutions to DEs 21 Summary n The symbolic toolbox can be used to find the closed form solutions for differential equations where they exist n The symbolic toolbox can be simultaneously solve a system of differential equations n Other Matlab commands can be used to numerically solve systems of differential equations if closed forms do not exist

Similar presentations

OK

Copyright © 2005. The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.

Copyright © 2005. The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on image sensor Ppt on time response analysis control Ppt on instrument landing system Ppt on layout design rules Ppt on job evaluation questionnaire Ppt on computer graphics and virtual reality Ppt on construction in maths Ppt on condition monitoring of transformer Numeric display ppt on tv Ppt on angle subtended by an arc of a circle