Appendix 3B MATLAB Functions for Modeling and Time-domain analysis

Similar documents
ECE 203 LAB 1 MATLAB CONTROLS AND SIMULINK

2 Solving Ordinary Differential Equations Using MATLAB

CDS 101/110: Lecture 3.1 Linear Systems

9. Introduction and Chapter Objectives

ECE 3793 Matlab Project 3

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

CDS 101/110: Lecture 3.1 Linear Systems

CHAPTER 6 STATE SPACE: FREQUENCY RESPONSE, TIME DOMAIN

OKLAHOMA STATE UNIVERSITY

CDS 101: Lecture 4.1 Linear Systems

Laboratory handouts, ME 340

AMS 27L LAB #8 Winter 2009

ECE 3793 Matlab Project 3 Solution

MAT 275 Laboratory 7 Laplace Transform and the Symbolic Math Toolbox

DSP First. Laboratory Exercise #10. The z, n, and ˆω Domains

STATE VARIABLE (SV) SYSTEMS

Lecture 8: Calculus and Differential Equations

Lecture 8: Calculus and Differential Equations

Inverted Pendulum. Objectives

Differential Equations and Lumped Element Circuits

Manifesto on Numerical Integration of Equations of Motion Using Matlab

MAT 275 Laboratory 4 MATLAB solvers for First-Order IVP

CYBER EXPLORATION LABORATORY EXPERIMENTS

MAT 275 Laboratory 4 MATLAB solvers for First-Order IVP

MATHEMATICAL MODELING OF CONTROL SYSTEMS

MODERN CONTROL DESIGN

EE 4343/ Control System Design Project

LABORATORY INSTRUCTION MANUAL CONTROL SYSTEM I LAB EE 593

Modeling and Experimentation: Compound Pendulum

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

Ordinary Differential Equations (ODE)

MAT 275 Laboratory 4 MATLAB solvers for First-Order IVP

EE Experiment 11 The Laplace Transform and Control System Characteristics

Outline. Classical Control. Lecture 1

Chapter 9b: Numerical Methods for Calculus and Differential Equations. Initial-Value Problems Euler Method Time-Step Independence MATLAB ODE Solvers

Richiami di Controlli Automatici

APPENDIX 1 MATLAB AND ANSYS PROGRAMS

Solving systems of first order equations with ode Systems of first order differential equations.

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

Chapter 6 - Solved Problems

MATLAB BASICS. Instructor: Prof. Shahrouk Ahmadi. TA: Kartik Bulusu

CHAPTER 12 TIME DOMAIN: MODAL STATE SPACE FORM

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

Signal Processing First Lab 11: PeZ - The z, n, and ˆω Domains

Lab 1: Dynamic Simulation Using Simulink and Matlab

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Mechanical Engineering 2.04A Systems and Controls Spring 2013

The Nonlinear Pendulum

Solving ODEs and PDEs in MATLAB. Sören Boettcher

1 Introduction & Objective. 2 Warm-up. Lab P-16: PeZ - The z, n, and O! Domains

Exam in Systems Engineering/Process Control

The Laplace Transform

The Laplace Transform

Lesson 9: Predator-Prey and ode45

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Mechanical Engineering Dynamics and Control II Fall 2007

Laboratory handout 5 Mode shapes and resonance

INTRODUCTION TO TRANSFER FUNCTIONS

EE C128 / ME C134 Final Exam Fall 2014

MATH2071: LAB 1(b): Using Matlab ODE solvers. This version of the first lab is intended only for students who have already taken Math 2070.

University of Alberta ENGM 541: Modeling and Simulation of Engineering Systems Laboratory #7. M.G. Lipsett & M. Mashkournia 2011

Introduction to Feedback Control

AM205: Assignment 3 (due 5 PM, October 20)

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

EE -213 BASIC CIRCUIT ANALYSIS LAB MANUAL

EE -213 BASIC CIRCUIT ANALYSIS LAB MANUAL

Department of Electrical and Computer Engineering. EE461: Digital Control - Lab Manual

Physics 584 Computational Methods

1 Overview of Simulink. 2 State-space equations

Modeling & Simulation 2018 Lecture 12. Simulations

Bfh Ti Control F Ws 2008/2009 Lab Matlab-1

Today (10/23/01) Today. Reading Assignment: 6.3. Gain/phase margin lead/lag compensator Ref. 6.4, 6.7, 6.10

1 Introduction to MATLAB

EEL2216 Control Theory CT1: PID Controller Design

TUTORIAL: STATE VARIABLES and MATLAB

MAE 143B - Homework 7

Driven, damped, pendulum

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

Nonlinear Oscillators: Free Response

APPLICATIONS FOR ROBOTICS

Übersetzungshilfe / Translation aid (English) To be returned at the end of the exam!

Matlab homework assignments for modeling dynamical systems

24, B = 59 24, A = 55

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

EEE 480 LAB EXPERIMENTS. K. Tsakalis. November 25, 2002

The Nonlinear Pendulum

Lab 1g: Horizontally Forced Pendulum & Chaotic Motion

Solution to Homework Assignment 1

ME scope Application Note 28

Time Response of Systems

EE nd Order Time and Frequency Response (Using MatLab)

Bangladesh University of Engineering and Technology. EEE 402: Control System I Laboratory

Time Response of Dynamic Systems! Multi-Dimensional Trajectories Position, velocity, and acceleration are vectors

Numerical Algorithms for ODEs/DAEs (Transient Analysis)

2D Plotting with Matlab

Stability of CL System

Using MATLB for stability analysis in Controls engineering Cyrus Hagigat Ph.D., PE College of Engineering University of Toledo, Toledo, Ohio

Ordinary Differential Equations (ode)

Control System Engineering

2.010 Fall 2000 Solution of Homework Assignment 1

Multivariable Control. Lecture 03. Description of Linear Time Invariant Systems. John T. Wen. September 7, 2006

Introduction to Modern Control MT 2016

Transcription:

Appendix 3B MATLAB Functions for Modeling and Time-domain analysis MATLAB control system Toolbox contain the following functions for the time-domain response step impulse initial lsim gensig damp ltiview Step response. Impulse response. Response of state-space system with given initial state. Response to arbitrary inputs. Generate input signal for LSIM. Natural frequency and damping of system poles. Response analysis GUI (LTI Viewer). Given a transfer function of a closed-loop control system, the function step(num, den) produces the step response plot with the time vector automatically determined. If the closed-loop system is defined in state space, we use step(a, B, C, D), step(a, B, C, D, t) or step(a, B, C, D, iu, t) uses the supplied time vector t. The scalar iu specifies which input is to be used for the step response. If the above commands are invoked with the lefthand argument [x, y, t], the output vector y, the state response x, and the time vector t are returned, and we need to use plot function to obtain the plot. Similarly for impulse, initial, and lsim. Example B.1 Obtain the unit step response for the system with the following closed-loop transfer function Cs ( ) 5(1 + 0.4 s) = Rs () (1 + 0.16 s)( s + 6s+ 5) Use the damp function to obtain the roots of the characteristic equation, the corresponding damping function, and natural frequencies The following commands num=5*[0.4 1]; den = conv([1 0.16], [1 6 5]); step(num, den), grid T = tf(num, den) damp(t) % multiplies the two polynomials % obtains the step response plot % returns roots of C.E., damping ratio, wn 3B.1

Example B. Figure B.1 Step response of Example 1 Eigenvalue Damping Freq. (rad/s) -3.00e+000 + 4.00e+000i 6.00e-001 5.00e+000-3.00e+000-4.00e+000i 6.00e-001 5.00e+000-6.5e+000 1.00e+000 6.5e+000 The closed-loop transfer function of a control system is described by the following thirdorder transfer function Cs ( ) 750 = T() s = 3 Rs () s + 36s + 05s+ 750 (a) Find the dominant poles of the system (b) Find a reduced-order model (c) Obtain the step response of the third-order system and the reduced-order system on the same figure plot (a) The command den = [ 1 36 05 750]; r = roots(den) result in r = -30-3 + 4i -3-4i 3B.

Therefore the transfer function is 750 5 T() s = = ( s+ 30)( s + 6s+ 5) (1 + 0.0333 s)( s + 6s+ 5) The time constant of the real pole at s = 30 isτ 1 = 1/30 which is negligible compared to the time constant of τ = 1/3 for the dominant poles 3± j4. Therefore the approximate reduced model transfer function is 5 T() s ( s + 6s+ 5) We use the following commands num1 = 750; % third-order system num den1 = [1 36 05 750]; % third-order system den num=5; % reduced-order system num den = [1 6 5]; % reduced-order system den t = 0: 0.01: ; c1 = step(num1, den1, t); % third-order system step response c = step(num, den, t); % reduced-order system step response plot(t, c1, 'b', t, c, 'r') % plots both response on the same figure grid, xlabel('t, seconds'), ylabel('c(t)') legend('third-order', 'Reduced-order') Figure B. Third-order and reduced-order Step response step responses of Example 1 3B.3

The LTI Viewer The Control System Toolbox LTI Viewer is a GUI that simplifies the analysis of linear, time-invariant systems. You use the LTI Viewer to view and compare the response plots of several linear models at the same time. You can generate time and frequency response plots to inspect key response parameters, such as rise time, maximum overshoot, and stability margins. Using mouse-driven interactions, you can select input and output channels from MIMO systems. The LTI Viewer can display up to six different plot types simultaneously, including step, impulse, Bode (magnitude and phase or magnitude only), Nyquist, Nichols, sigma, and pole/zero. The command syntax is ltiview( plot type, sys, extra) where sys is the transfer function name and plot type is one of the following responses: step impulse initial lsim bode nyquist nichols sigma Extra is an optional argument specifying the final time. Once an LTI Viewer is opened, the right-click on the mouse allows you to change the response type and obtain the system time-domain and frequency domain specifications, including: Plot Type Systems Characteristics Zoom Grid Properties changes the plot type selects any of the models loaded in the LTI Viewer displays key response characteristics and parameters zooms in and out of plot regions adds grids to your plots Property Editor, where you can customize plot attributes Example B.3 Use the ltiview to obtain the step response and the time-domain specifications for the control system shown in Figure 3. R() s 50s + 70 1 s + 7 ss ( + 1)( s+ 4) G () c s Gp () s Cs () Figure B.3 Block diagram for Example 3 3B.4

The following commands Gc = tf([50 70], [1 7]) Gp = tf([1], [1 5 4 0]); H = 1; G = series(gc, Gp) T = feedback(g, 1) ltiview('step', T) % transfer function Gc % transfer function Gp % connects Gc & Gp in cascade % obtains the closed loop transfer function result in Transfer function: 50 s + 70 --------------------------------- s^4 + 1 s^3 + 39 s^ + 78 s + 70 The system step response is obtained as shown in Figure 4. The mouse right-click is used to obtain the time-domain specifications. From File menu you can select Print to Figure option to obtain a Figure Window for the LTI Viewer for editing the graph. Figure B.4 Step response of Example B.3 For the time-domain analysis it is recommended to use the LTI Viewer, this will make it possible to obtain the time-domain specification with a simple right-click on the mouse. 3B.5

In addition it allows you to select the Plot type, which would enable you to find other type of time-domain responses as well as the frequency domain responses and specifications. MATLAB Functions for Numerical Solution of Differential Equations There are many other more powerful techniques for the numerical solution of nonlinear equations. A popular technique is the Runge-Kutta method, which is based on formulas derived by using an approximation to replace the truncated Taylor series expansion. The interested reader should refer to textbooks on numerical techniques. MATLAB provides several powerful functions for the numerical solution of differential equations. Two of the functions employing the Runge-Kutta-Fehlberg methods are ode3 and ode45, based on the Fehlberg second- and third-order pair of formulas for medium accuracy and forthand fifth-order pair for higher accuracy. These functions are as follows: ode3 ode45 ode113 ode15s ode3s ode3t ode3tb Solve non-stiff differential equations, low order method. Solve non-stiff differential equations, medium order method Solve non-stiff differential equations, variable order method. Solve stiff differential equations and DAEs, variable order method. Solve stiff differential equations, low order method. Solve moderately stiff ODEs and DAEs, trapezoidal rule. Solve stiff differential equations, low order method. The nth-order differential equation must be transformed into n first order differential equations and must be placed in an M-file that returns the state derivative of the equations. The formats for these functions are [t, x] = ode3('xprime', tspan, x0, option) where tspan =[t0, tfinal] is the time interval for the integration and x0 is a column vector of initial conditions at time t0. xprime is the state derivative of the equations, defined in a file named xprime.m. Commonly used options are scalar relative error tolerance 'RelTol' (1e-3 by default) and vector of absolute error tolerances 'AbsTol' (all components 1e-6 by default) Example B.4 Using MATLAB function ode3 obtain the numerical solution for the differential equation given by d θ B dθ g + + sinθ = 0 dt m dt l 3B.6

The above equation describes the motion of the simple pendulum derived in Lab Session 4 Case Study. Where m = 0.5 Kg, l = 0.613 m, B = 0.05 Kg-s/m, and g = 9.81 m/s. The initial angle at time t = 0 is θ (0) = 0.5and θ (0) = 0. First we write the above equation in state variable form. Let x1 velocity), then x = x 1 B g x = x sinx m l 1 = θ, and x = θ (angular The above equations are defined in a function file named pendulumeq.m as follows function xdot = pendulumeq(t, x); % Returns the state derivative m = 0.5; l = 0.613; B = 0.05; g = 9.81; xdot = [x(); -B/m*x()-g/l*sin(x(1))]; In a separate file named Lab3ExB4.m, the MATLAB function ode3 is used to obtain the solution of the given differential equations (defined in the file pendulumeq.m from 0 to 0 seconds. tspan = [0, 0]; % time interval x0 = [0.5; 0]; % initial condition [t, x] = ode3('pendulumeq', tspan, x0); theta = x(:, 1);omega = x(:, ); figure(1), plot(t, theta, 'b', t, omega, 'r'), grid xlabel('t, sec'), legend('\theta(t)', '\omega(t)') figure(), plot(theta, omega); xlabel('\theta, rad'), ylabel('\omega rad/s') title('state trajectory') Run Lab3ExB4 at the MATLAB prompt, the result is Figure B.5 Response of the pendulum described in Example B.4 3B.7

Example B.5 Using MATLAB function ode3 obtain the numerical solution for the nonlinear simultaneous differential equation given by Given dx dx x + x + t + t = t t dt dt dx dx x x t t t dt dt x 1 (0) = 1, and x (0) = 1 1 1 [0 40*cos(0.0* )] 30*sin(0.0* ) 13*exp(- )*sin( ) 1 3 1 4 + [0*sin(0.0* )] + [10 40*cos(0.0* ) = 40*exp( 0. )*cos( ) t Writing the above equations in matrix form, we have t 1 x1 0 40 cos 0.0t 30sin 0.0t x 1 13e sin t 3 4 x + 0. 0sin 0.0t 10 40 cos 0.0t = x t 40e cost Writing in compact form RX + LX = V Solving for X, we get X = L 1 [ V RX] (Note the correction) The above equations are defined in a function file named nlseq.m as follows function xdot = nlseq(t, x); % Returns the state derivative R = [-1 ; 3-4]; L = [0-40*cos(0.0*t) 30*sin(0.0*t) 0*sin(0.0*t) 10-40*cos(0.0*t)]; V = [13*exp(-t)*sin(t); 40* exp(-0.*t) *cos(t)]; xdot = inv(l)*(v - R*x); In a separate file named Lab3ExB5.m, the MATLAB function ode3 is used to obtain the solution of the given differential equations (defined in the nlseq.m from 0 to 30 seconds tspan = [0, 30]; % time interval x0 = [1; -1]; % initial condition [t, x] = ode3('nlseq', tspan, x0); plot(t, x), grid xlabel('t, sec'), legend('x_1(t)', 'x_(t)') 3B.8

Figure B.6 Response of the system described in Example B.5 3B.9