Solving Differential Equations Using MATLAB

Similar documents
Lecture 1. Scott Pauls 1 3/28/07. Dartmouth College. Math 23, Spring Scott Pauls. Administrivia. Today s material.

Using MATLAB with the Convolution Method

These videos and handouts are supplemental documents of paper X. Li, Z. Huang. An Inverted Classroom Approach to Educate MATLAB in Chemical Process

Solutions to Math 53 Math 53 Practice Final

MAE143A Signals & Systems - Homework 5, Winter 2013 due by the end of class Tuesday February 12, 2013.

EE 4314 Lab 1 Handout Control Systems Simulation with MATLAB and SIMULINK Spring Lab Information

Laboratory 1. Solving differential equations with nonzero initial conditions

Solutions of the Sample Problems for the Third In-Class Exam Math 246, Fall 2017, Professor David Levermore

The Volume of a Hypersphere

Lecture 2. Introduction to Differential Equations. Roman Kitsela. October 1, Roman Kitsela Lecture 2 October 1, / 25

Fourth Order RK-Method

20.6. Transfer Functions. Introduction. Prerequisites. Learning Outcomes

Math Shifting theorems

BMEN 398: MATLAB Module: Higher Order Differential Equations; SIMULINK Fall 2005 Updated 8/21/2005 Hart

Lecture Discrete dynamic systems

Final Exam Sample Problems, Math 246, Spring 2018

Third In-Class Exam Solutions Math 246, Professor David Levermore Thursday, 3 December 2009 (1) [6] Given that 2 is an eigenvalue of the matrix

The integrating factor method (Sect. 1.1)

20.3. Further Laplace Transforms. Introduction. Prerequisites. Learning Outcomes

9. Introduction and Chapter Objectives

DIFFERENTIAL EQUATIONS

Solving systems of ODEs with Matlab

Solutions to Homework 3

Course roadmap. ME451: Control Systems. Example of Laplace transform. Lecture 2 Laplace transform. Laplace transform

ENGI Second Order Linear ODEs Page Second Order Linear Ordinary Differential Equations

MAT 275 Laboratory 7 Laplace Transform and the Symbolic Math Toolbox

One-Sided Laplace Transform and Differential Equations

Linear algebra and differential equations (Math 54): Lecture 20

MAE 143B - Homework 7

. For each initial condition y(0) = y 0, there exists a. unique solution. In fact, given any point (x, y), there is a unique curve through this point,

Chemical Engineering 436 Laplace Transforms (1)

CHEE 319 Tutorial 3 Solutions. 1. Using partial fraction expansions, find the causal function f whose Laplace transform. F (s) F (s) = C 1 s + C 2

Control Systems I. Lecture 6: Poles and Zeros. Readings: Emilio Frazzoli. Institute for Dynamic Systems and Control D-MAVT ETH Zürich

ODE Runge-Kutta methods

Math 308 Week 8 Solutions

Lecture 2 : Mathematical Review

Time Response of Systems

EE Homework 12 - Solutions. 1. The transfer function of the system is given to be H(s) = s j j

Dynamic Characteristics. Lecture04 SME3242 Instrumentation

Second In-Class Exam Solutions Math 246, Professor David Levermore Thursday, 31 March 2011

25. Chain Rule. Now, f is a function of t only. Expand by multiplication:

System Simulation using Matlab

A First Course on Kinetics and Reaction Engineering Example S5.1

We begin exploring Euler s method by looking at direction fields. Consider the direction field below.

Section 6.5 Impulse Functions

Matlab Controller Design. 1. Control system toolbox 2. Functions for model analysis 3. Linear system simulation 4. Biochemical reactor linearization

MA 201: Partial Differential Equations Lecture - 2

Mathematical Computing

Review: control, feedback, etc. Today s topic: state-space models of systems; linearization

APPLICATIONS OF FD APPROXIMATIONS FOR SOLVING ORDINARY DIFFERENTIAL EQUATIONS

Ordinary Differential Equations. Session 7

NCERT solution for Integers-2

Higher-order ordinary differential equations

37. f(t) sin 2t cos 2t 38. f(t) cos 2 t. 39. f(t) sin(4t 5) 40.

MECH : a Primer for Matlab s ode suite of functions

Lecture 7 - Separable Equations

Introduction to ODEs in Scilab

Solutions to Final Exam Sample Problems, Math 246, Spring 2011

1D Wave PDE. Introduction to Partial Differential Equations part of EM, Scalar and Vector Fields module (PHY2064) Richard Sear.

EE 380. Linear Control Systems. Lecture 10

ECE 3793 Matlab Project 3

REVERSE CHAIN RULE CALCULUS 7. Dr Adrian Jannetta MIMA CMath FRAS INU0115/515 (MATHS 2) Reverse Chain Rule 1/12 Adrian Jannetta

Introduction ODEs and Linear Systems

ECE 3793 Matlab Project 3 Solution

M A : Ordinary Differential Equations

E2.5 Signals & Linear Systems. Tutorial Sheet 1 Introduction to Signals & Systems (Lectures 1 & 2)

UNIVERSITY OF SOUTHAMPTON. A foreign language dictionary (paper version) is permitted provided it contains no notes, additions or annotations.

Finding Transfer Functions of Circuits Using State-Space

Vector Fields and Solutions to Ordinary Differential Equations using MATLAB/Octave

Differential Equation (DE): An equation relating an unknown function and one or more of its derivatives.

Intro to Research Computing with Python: Partial Differential Equations

Math 216 Second Midterm 19 March, 2018

Teaching State Variable Feedback to Technology Students Using MATLAB and SIMULINK

MAT 275 Laboratory 4 MATLAB solvers for First-Order IVP

Lecture 14 - Using the MATLAB Control System Toolbox and Simulink Friday, February 8, 2013

ES205 Analysis and Design of Engineering Systems: Lab 1: An Introductory Tutorial: Getting Started with SIMULINK

1.1 Differential Equation Models. Jiwen He

Fall 2001, AM33 Solution to hw7

FIRST-ORDER ORDINARY DIFFERENTIAL EQUATIONS II: Graphical and Numerical Methods David Levermore Department of Mathematics University of Maryland

(1 + 2y)y = x. ( x. The right-hand side is a standard integral, so in the end we have the implicit solution. y(x) + y 2 (x) = x2 2 +C.

(f g)(t) = Example 4.5.1: Find f g the convolution of the functions f(t) = e t and g(t) = sin(t). Solution: The definition of convolution is,

Solution of ODEs using Laplace Transforms. Process Dynamics and Control

Introduction to Differential Equations

Laplace Transforms Chapter 3

Lecture 8 Finite Impulse Response Filters

Lab 1: Dynamic Simulation Using Simulink and Matlab

Raktim Bhattacharya. . AERO 422: Active Controls for Aerospace Vehicles. Dynamic Response

Some tools and methods for determination of dynamics of hydraulic systems

Lecture Notes in Mathematics. Arkansas Tech University Department of Mathematics

FORTRAN 77 Lesson 7. Reese Haywood Ayan Paul

Relativistic Electrodynamics

Dr. Ian R. Manchester

Mathematics 22: Lecture 7

CDS 101: Lecture 4.1 Linear Systems

Nov : Lecture 20: Linear Homogeneous and Heterogeneous ODEs

Exercises for Multivariable Differential Calculus XM521

Systems of Ordinary Differential Equations

How to simulate in Simulink: DAE, DAE-EKF, MPC & MHE

MA 201, Mathematics III, July-November 2018, Laplace Transform (Contd.)

Mathematics II. Tutorial 2 First order differential equations. Groups: B03 & B08

Transcription:

Solving Differential Equations Using MATLAB Abraham Asfaw aasfaw.student@manhattan.edu November 28, 2011 1 Introduction In this lecture, we will follow up on lecture 2 with a discussion of solutions to Ordinary Differential Equations (ODEs) using MATLAB. We will discuss standard methods of solution, and an additional method based on simulation of linear systems. Throughout the lecture, examples will be used to demonstrate these methods. Interested readers should refer to the various references available online on related topics, such as numerical methods and the solutions of partial differential equations. In order to encourage a trial-and-error method of learning the methods contained herein, no MATLAB outputs are shown. 2 Solving ODEs Let us begin with a simple example. dy dx = y(x) The MATLAB code to solve this ODE with no initial conditions is shown below. ODE1 = Dy = y ODE1solved = dsolve(ode1, x ) We can specify initial conditions for the ODE as follows. 1

initconds = y(0) = 5 ODE1solved = dsolve(ode1, initconds, x ) As shown in the previous lectures, MATLAB makes plotting functions easy. We can plot our solved function as follows. x = -5:0.01:5; y_values = eval(vectorize(ode1solved)); plot(x,y_values) The same ideas apply to higher ODEs. Here, we solve a second-order ODE with initial values at y(0) and y (0). We then plot the function in the range [-5,5]. ODE2 = 3*D2y - Dy + 6*y = 6*sin(t) + 2*cos(t) initconds = y(0) = 1, Dy(0)=2 ODE2solved = simplify(dsolve(ode2, initconds)); pretty(ode2solved) t = -5:0.01:5; y_values = eval(vectorize(ode2solved)); plot(t,y_values) 3 Solving Systems of ODEs Systems of ODEs can be solved in a similar manner. One simply defines each equation as before. The only thing that chances is the return value of the dsolve function, which is now an array containing the explicit solutions of each of the functions in the system. sysode1 = Dx = 2*x + 3*z sysode2 = Dy = 6*z - y sysode3 = Dz = 3*y - 12*x initconds = x(1) = 5, y(2) = 3, z(9) = 0 [x,y,z] = dsolve(sysode1,sysode2, sysode3, initconds) 2

4 Laplace Transforms Laplace transforms are handy in solutions of differential equations when the transforms of the forcing functions are known and can easily be inverted with slight modification. Typically, these include sinusoidal forcing functions, making this method ideal in the study of linear systems. Here is an example where we solve the differential equation below with zero initial conditions. 3 d2 y dt dy + 6y = 6sin(t) + 2cos(t) 2 dt syms s; syms t; lhs = 3*s^2 - s + 6; rhs = laplace(6*sin(t)) + laplace(2*cos(t)); soln = simplify(ilaplace(rhs*1/lhs)) 5 Solving ODEs Using Simulation This will be demonstrated in the lectures. The basic theory is as follows. Assume that we would like to simulate the system characterized by the following differential equation. There are several ways of doing so. One such way is to take the Laplace Transform of both sides, thereby acquiring a transfer function. In MATLAB, particularly in Simulink, there is a transfer function block which will take the coefficients of the numerator and denominator to generate the transfer function. That block can be fed several types of inputs, and conclusions can be made about the outputs. In this lecture, we discuss another interesting method of solution, namely the use of block diagrams in representing (and solving) differential equations. Consider the equation 6 d2 y dt + 5dy + 9y = 2u(t) 2 dt with some initial conditions y(0) and y (0). Note that we are dealing with a causal system in which the forcing function begins at zero. We can rewrite the above ODE as d dt ( ) dy = 1 ( 5 dy ) 9y + 2u(t) dt 6 dt 3

Let us integrate both sides of the differential equation twice ignoring the initial conditions for the moment. y(t) = 1 [ ( ) ( ) ( )] 5 y(t) 9 y(t) + 2 u(t) 6 In Simulink, such a description is easily represented as shown below. Note that the initial conditions are fed to the integrators. Figure 1: Simulink Model of an ODE We can add a To Workspace block to the block diagram to observe the output in a normal MATLAB plot instead of the scope in Simulink. Assuming that the output variable of such a block is simout, the following code will plot the simulation outputs. Note the use of the dots to navigate through the simout struct. plot(tout, simout.signals.values) 4

6 Conclusion MATLAB presents several tools for modeling linear systems. These tools can be used to solve differential equations arising in such models, and to visualize the input-output relations. Further reading on this topic would cover material such as system modeling using commands such as sys and tf, advanced usage of Simulink in laboratory measurement, and modeling tied systems using numerical methods. The interested reader is referred to the internet, where a simple search for Modeling Dynamical Systems Using Simulink points to several interesting introductory articles on MATLAB s true power in the process of modeling linear systems. 5