ENSC 383- Feedback Control Summer 2010 TAs:Kaveh Kianfar, Esmaeil Tafazzoli G(s) U(s) inputY(s) output MATLAB Tutorial 1.

Slides:



Advertisements
Similar presentations
Laplace Transform Math Review with Matlab:
Advertisements

The Inverse Laplace Transform
ECEN/MAE 3723 – Systems I MATLAB Lecture 3.
For System Dynamics & Control
1 Eng. Mohamed El-Taher Eng. Ahmed Ibrahim. 2 1.FUNCTION SUMMARY polyfun  Polynomial functions are located in the MATLAB polyfun directory. For a complete.
H(s) x(t)y(t) 8.b Laplace Transform: Y(s)=X(s) H(s) The Laplace transform can be used in the solution of ordinary linear differential equations. Let’s.
CSE 123 Symbolic Processing. Declaring Symbolic Variables and Constants To enable symbolic processing, the variables and constants involved must first.
4. System Response This module is concern with the response of LTI system. L.T. is used to investigate the response of first and second order systems.
Chapter 7 Laplace Transforms. Applications of Laplace Transform notes Easier than solving differential equations –Used to describe system behavior –We.
EE-2027 SaS, L13 1/13 Lecture 13: Inverse Laplace Transform 5 Laplace transform (3 lectures): Laplace transform as Fourier transform with convergence factor.
Laplace Transforms Important analytical method for solving linear ordinary differential equations. - Application to nonlinear ODEs? Must linearize first.
Matlab Matlab is a powerful mathematical tool and this tutorial is intended to be an introduction to some of the functions that you might find useful.
1 ECEN Automatic Control Systems Matlab Lecture 1 Introduction and Control Basics Presented by Moayed Daneshyari OKLAHOMA STATE UNIVERSITY.
1 Lavi Shpigelman, Dynamic Systems and control – – Linear Time Invariant systems  definitions,  Laplace transform,  solutions,  stability.
LTI system stability Time domain analysis
Concept of Transfer Function Eng. R. L. Nkumbwa Copperbelt University 2010.
Chapter 3 1 Laplace Transforms 1. Standard notation in dynamics and control (shorthand notation) 2. Converts mathematics to algebraic operations 3. Advantageous.
5.7 Impulse Functions In some applications, it is necessary to deal with phenomena of an impulsive nature—for example, voltages or forces of large magnitude.
Feedback Control Systems (FCS) Dr. Imtiaz Hussain URL :
Autumn 2008 EEE8013 Revision lecture 1 Ordinary Differential Equations.
Sistem Kontrol I Kuliah II : Transformasi Laplace Imron Rosyadi, ST 1.
SE 207: Modeling and Simulation Introduction to Laplace Transform
MESB 374 System Modeling and Analysis Inverse Laplace Transform and I/O Model.
MATLAB Basics. The following screen will appear when you start up Matlab. All of the commands that will be discussed should be typed at the >> prompt.
Professor Walter W. Olson Department of Mechanical, Industrial and Manufacturing Engineering University of Toledo Block Diagrams H(s) + - R(s) Y(s) E(s)
ECE 4115 Control Systems Lab 1 Spring 2005
Solving DEs etc. Laplace transforming derivatives Etc.
1 Inverse Laplace Transform Note that most of the transforms are written as fractions.
Prepared by Mrs. Azduwin Binti Khasri
Rational Transforms Consider the problem of finding the inverse Laplace transform for: where {ai} and {bi} are real numbers, and M and N are positive.
1 Z-Transform. CHAPTER 5 School of Electrical System Engineering, UniMAP School of Electrical System Engineering, UniMAP NORSHAFINASH BT SAUDIN
Modified by Albert W.J. Hsue,
Chapter 6 The Laplace Transform and the Transfer Function Representation.
Professor Walter W. Olson Department of Mechanical, Industrial and Manufacturing Engineering University of Toledo Transfer Functions.
ECE 4115 Control Systems Lab 1 Spring 2005 Chapter 1 System models.
Chapter 4 Transfer Function and Block Diagram Operations § 4.1 Linear Time-Invariant Systems § 4.2 Transfer Function and Dynamic Systems § 4.3 Transfer.
MATLAB-Tutorial 2 Class ECES-304 Presented by : Shubham Bhat.
MESB374 Chapter8 System Modeling and Analysis Time domain Analysis Transfer Function Analysis.
Lecture 5: Transfer Functions and Block Diagrams
Chapter 3 Dynamic Response The Block Diagram Block diagram is a graphical tool to visualize the model of a system and evaluate the mathematical relationships.
Subsea Control and Communications Systems
SURF 2015 lecture: Jun 24, 2015 Koji Arai – LIGO Laboratory / Caltech LIGO-G v1.
Chapter 7 The Laplace Transform
, Free vibration Eigenvalue equation EIGENVALUE EQUATION
Modeling Transient Response So far our analysis has been purely kinematic: The transient response has been ignored The inertia, damping, and elasticity.
Lecture 4: The z-Transform 1. The z-transform The z-transform is used in sampled data systems just as the Laplace transform is used in continuous-time.
CONTROL SYSTEM DESIGN by using MATLAB
디지털 제어 Sun Moon University 1 of 32 목 차 7. Stability Kyoung-Chul DIGITAL CONTROL.
DYNAMIC BEHAVIOR OF PROCESSES :
Properties of the z-Transform
Automatic Control Theory CSE 322
H(s) 8.b Laplace Transform:
MESB374 System Modeling and Analysis Transfer Function Analysis
Laplace Transforms Chapter 3 Standard notation in dynamics and control
© Dr. Elmer P. Dadios - DLSU Fellow & Professor
Chap2. Modeling in the Frequency Domain
Chapter 4 Transfer Function and Block Diagram Operations
Background Knowledge Expected
Lecture 3: Solving Diff Eqs with the Laplace Transform
Laplace Transform Properties
ME375 Handouts - Fall 2002 MESB374 Chapter8 System Modeling and Analysis Time domain Analysis Transfer Function Analysis.
Instructor: Jongeun Choi
Control System Toolbox
4. Closed-Loop Responses Using the Laplace Transform Method
Example 1: Find the magnitude and phase angle of
Chapter 2. Mathematical Foundation
ECEN 605 Linear Control Systems Instructor: S.P. Bhattacharyya
Laplace Transforms Important analytical method for solving linear ordinary differential equations. - Application to nonlinear ODEs? Must linearize first.
Laplace Transforms Important analytical method for solving linear ordinary differential equations. - Application to nonlinear ODEs? Must linearize first.
Presentation transcript:

ENSC 383- Feedback Control Summer 2010 TAs:Kaveh Kianfar, Esmaeil Tafazzoli G(s) U(s) inputY(s) output MATLAB Tutorial 1

Outline Starting Matlab Basics Modeling Control toolbox 2 Outline

M-file When writing a program in matlab save it as m-file ( filename.m) 2 types of M-file 1- script (has no input and output, simply execute commands) 2- function (need input, starts with keyword “function”) function [y z]=mfunc(x) y=(x*x')^.5; % norm of x z=sum(x)/length(x); %% using 'sum' function end m file 3

Present polynomial with coefficients vector x = [ ]; P3=poly([ ]) rootsP3=roots(P3) P5=conv([1 2],[1 5]) Poly converts roots to coefficients of a polynomial: 4 Polynomials

p=poly([-2 1 5]) R=roots(p) x=-3:0.1:6; y=p(1)*x.^3+p(2)*x.^2+p(3)*x+p(4); plot(x,y) grid p = R = Polynomials

numf=[ ]; denf=[1 0 1]; [r,p,k]=residue(numf,denf) Partial Fraction Expansion 6

Roots of numerators are “zeros” of a system, Roots of denominators are “poles” of a system. G(s) U(s) inputY(s) output Dynamic system Representation usingTransfer Function 7 Im Re S-plane zero pole

 Command “tf” by defining the  Command “zpk”  Using s=tf(‘s’), then for example: Transfer Function in MATLAB 8

 tf2zp: converts the numerator, denominator from coefficient to roots. [Z,P,K] = TF2ZP(NUM,DEN) Ex.: [z,p,k]=tf2zp([1 1],[1 2 1]) z=-1, p=-1;-1, k=1  zp2tf: converts the numerator, denominator from roots to coefficient. [NUM,DEN] = ZP2TF(Z,P,K) Transfer Function in MATLAB 9

G=series(G 1,G 2 ) or alternatively: G=parallel (G 1,G 2 ) or alternatively: Interconnection between blocks G 1 (s)G 2 (s) G 1 (s) G 2 (s) u y uy 10

Feedback: or alternatively for Negative feedback: Interconnection between blocks G 1 (s) H(s) - u y 11

Syms s t :defines s, and t as symbolic variable syms s a t 1)G4=laplace(exp(t)): G4 =1/(s - 1) 2)G5=laplace(exp(-t)): G5 =1/(s + 1) 3)G6=laplace(sin(a*t)): G6 =a/(a^2 + s^2) Hint:ilaplace(F,s,t): computes Inverse Laplace transform of F on the complex variable s and returns it as a function of the time, t. ilaplace(a/(s^2+a^2),s,t)=(a*sin(t*(a^2)^(1/2)))/(a^2)^(1/2) Symbolic computation in MATLAB 12

Ex.: A=[1,1;0,1];syms t; Q=expm(A*t) Hint: expm(M) computes the matrix exponential of M. G=laplace(Q,t,s) gives: G = [ 1/(s - 1), 1/(s - 1)^2] [ 0, 1/(s - 1)] Symbolic computation in MATLAB 13

System Step, impulse, other inputs Matlab commands: lsim Simulate LTI model response to arbitrary inputs sys=tf(num,den); t=0:dt:final_t; u=f(t); [y t]=lsim(sys,u,t) step Simulate LTI model response to step input step(sys) special case of lsim response 14 System Response

Transient response: x(t)=x 0 *exp(a*t) “ if a<0,it’s stable ”. First order systems 15 Im Re s-plane s=-a

When “a” is a complex number: t=0:0.1:5; a=-1+4*i; % a is complex with negative real part f=exp(a*t); X=real(f); Y=imag(f); plot(X,Y) xlabel('Re') ylabel('Im') axis('square') Plot(t,f) Exp(a*t) 16

First order systems(cont’d) When “a” is complex, with Negative real part in polar coordinates: Rho=sqrt(X.^2+Y.^2); Theta=atan2(Y,X); polar(Theta,Rho) 17

Second order System In Laplace domain: Like mass-spring-damper 18 s=tf('s') w=1; zeta=[ ]; for i=1:length(zeta) G=w^2/(s^2+2*zeta(i)*w*s+w^2) step(G,10) hold on end Second order systems

19 Second order systems s-plane Im Re Damping ratio is constant, w n changes. s=tf('s') zeta=0.5 w=[sqrt(12) 4 sqrt(20)]; for i=1:length(w) G=(w(i))^2/(s^2+2*zeta*w(i)*s+(w(i))^2) step(G,3) hold on end

Undamped system(mass-spring) Damping ratio is zero: 20 Second order systems w=[1 2]; for i=1:length(w) G=tf(w(i)^2,[1 0 w(i)^2]); step(G,20) hold on end

21 Dynamic system representation m System Transfer Function

22 MATLAB code k=.2; % spring stiffness coefficient b=.5; % damping coefficient m=1; % mass A=[0 1;-k/m -b/m]; % Represent A. B=[0;1/m]; % Represent column vector B. C=[1 0]; % Represent row vector C. D=0; % Represent D. F=ss(A,B,C,D) % Create an LTI object and display. step(F) [num den]=ss2tf(A,B,C,D) Gs=tf(num,den) % system transfer function

Step Response 23 Step Response

24 Ordinary differential equations function dx=lin1(t,x) dx=zeros(2,1); dx(1)=-x(1); dx(2)=-2*x(2); A=[-1 0;0 -2]; [u,v]=eig(A) In workspace: 10], [a(i) b(j)]); plot(X(:,1),X(:,2)) [u.v]=eig(A) u = Hint:For using ode command, the diff. equations should be written in the first order format,i.e. a second order diff. eq. should be written as two first order diff. equations.

25 function dx=pendulum(t,x) dx=zeros(2,1) dx(1)=x(2); dx(2)=-0.5*x(2)-sin(x(1)); 10], [a(i) 0]); plot(X(:,1),X(:,2)) Nonlinear Differential eq. of a pendulum g Viscose Damping termGravity term Angle Angular velocity