MATLAB BASICS ECEN 605 Linear Control Systems Instructor: S.P. Bhattacharyya.

Slides:



Advertisements
Similar presentations
Laplace Transform Math Review with Matlab:
Advertisements

Math Review with Matlab:
Root Locus Diagrams Professor Walter W. Olson
MATLAB – A Computational Methods By Rohit Khokher Department of Computer Science, Sharda University, Greater Noida, India MATLAB – A Computational Methods.
STATE SPACE MODELS MATLAB Tutorial.
ECEN/MAE 3723 – Systems I MATLAB Lecture 3.
Lecture 5.
Introduction to Matlab
For System Dynamics & Control
Matlab Graphics S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Introduction to Matlab: 2D Graphics.
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.
Introduction to MATLAB for Biomedical Engineering BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Lesson 2: Element-wise vs. matrix operations.
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.
MATLAB – What is it? Computing environment / programming language Tool for manipulating matrices Many applications, you just need to get some numbers in.
Lab5 (Signal & System) Instructor: Anan Osothsilp Date: 20 Feb 07 Due Date 09 March 07.
CSE 123 Symbolic Processing. Declaring Symbolic Variables and Constants To enable symbolic processing, the variables and constants involved must first.
Bode Magnitude Plots Constructed Bode Actual Bode
MATLAB’s extensive, device-independent plotting capabilities are one of its most powerful features. They make it very easy to plot any data at any time.
Frequency Response Methods and Stability
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.
Poles and Zeros and Transfer Functions
Exam #3 Review: Comprehensive Exam Class 14.2 Palm Matlab Book Ch. 1-5.
1 ECEN Automatic Control Systems Matlab Lecture 1 Introduction and Control Basics Presented by Moayed Daneshyari OKLAHOMA STATE UNIVERSITY.
Dr. Jie Zou PHY Welcome to PHY 3320 Computational Methods in Physics and Engineering.
Matlab intro The Environment
MATLAB-Tutorial 3 Class ECES-304 Presented by : Shubham Bhat.
MATLAB INTRO CONTROL LAB1  The Environment  The command prompt Getting Help : e.g help sin, lookfor cos Variables Vectors, Matrices, and Linear Algebra.
IC3003 B ASIC S CIENTIFIC C OMPUTING Lecture 1 Monday 08:30-11:30 U204a.
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
A Brief Introduction to Matlab Laila Guessous Dept. of Mechanical Engineering Oakland University.
Numerical Computation Lecture 2: Introduction to Matlab Programming United International College.
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.
ECE 4115 Control Systems Lab 1 Spring 2005
Dan O. Popa, Linear Systems EE 3317, Spring 2009 Week 2, Lectures 2-3: Review These lectures cover math concepts related to: -White Box Systems Examples:
Circuits II EE221 Unit 4 Instructor: Kevin D. Donohue
Modified by Albert W.J. Hsue,
ECE 4115 Control Systems Lab 1 Spring 2005 Chapter 1 System models.
ELECTRICA L ENGINEERING Principles and Applications SECOND EDITION ALLAN R. HAMBLEY ©2002 Prentice-Hall, Inc. Chapter 6 Frequency Response, Bode Plots,
MATLAB-Tutorial 2 Class ECES-304 Presented by : Shubham Bhat.
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
ELECTRICAL ENGINEERING: PRINCIPLES AND APPLICATIONS, Third Edition, by Allan R. Hambley, ©2005 Pearson Education, Inc. CHAPTER 6 Frequency Response, Bode.
Automatic Control By Dr. / Mohamed Ahmed Ebrahim Mohamed Web site:
سیستمهای کنترل خطی پاییز 1389 بسم ا... الرحمن الرحيم دکتر حسين بلندي - دکتر سید مجید اسما عیل زاده.
CONTROL SYSTEM DESIGN by using MATLAB
Variable-Frequency Response Analysis Network performance as function of frequency. Transfer function Sinusoidal Frequency Analysis Bode plots to display.
1 Eeng 224 Chapter 14 Frequency Response Huseyin Bilgekul Eeng 224 Circuit Theory II Department of Electrical and Electronic Engineering Eastern Mediterranean.
1 Eeng 224 Chapter 14 Frequency Response Huseyin Bilgekul Eeng 224 Circuit Theory II Department of Electrical and Electronic Engineering Eastern Mediterranean.
Outline What is MATLAB MATLAB desktop Variables, Vectors and Matrices Matrix operations Array operations Built-in functions: Scalar, Vector, Matrix Data.
디지털 제어 Sun Moon University 1 of 32 목 차 7. Stability Kyoung-Chul DIGITAL CONTROL.
How to use MATLAB (using M-files) Double click this icon To start Matlab 6.5.
Lesson 21: Methods of System Analysis
Lesson 22: Determining Control Stability Using Bode Plots
ECE 1304 Introduction to Electrical and Computer Engineering
Lesson 15: Bode Plots of Transfer Functions
© Dr. Elmer P. Dadios - DLSU Fellow & Professor
2nd Homework: Cervical Syndrome
6. Nyquist Diagram, Bode Diagram, Gain Margin, Phase Margin,
MATLAB DENC 2533 ECADD LAB 9.
ECEN Automatic Control Systems Introduction and Control Basics
MATLAB How to use (using M-files) Double click this icon
Control System Toolbox
ELEC 202 Circuit Analysis II
MATLAB How to use (using M-files) Double click this icon
1 ECEN Automatic Control Systems Matlab Lecture 1 Introduction and Control Basics Presented by Moayed Daneshyari OKLAHOMA STATE UNIVERSITY.
Hanani binti Abdul Wahab 24 September 2008
دکتر حسين بلندي- دکتر سید مجید اسما عیل زاده
Control System Toolbox (Part-III)
ECEN 605 Linear Control Systems Instructor: S.P. Bhattacharyya
Presentation transcript:

MATLAB BASICS ECEN 605 Linear Control Systems Instructor: S.P. Bhattacharyya

STARTING MATLAB You can start MATLAB by double-clicking on the MATLAB icon or invoking the application from the Start menu of Windows. The main MATLAB window will then pop-up.

BASIC OPERATION MATLAB is based on matrix and vector algebra; even scalars are treated as 1x1 matrices. e.g. v = [ ]; t = 0:.1:10; k = 0:10; M = [1 2 4; 3 6 8];

APPROACH TRY EXPLORING ALL THE COMMANDS INITIALLY TO GET FAMILIARIZED. TAKE UP EXAMPLES AND SOLVE THEM TRY THE ASSIGNMENT QUESTIONS

SPECIAL MATRICES There are a number of special matrices that can be defined: null matrix: M = [ ]; nxm matrix of zeros: M = zeros(n,m); nxm matrix of ones: M = ones(n,m); nxn identity matrix: M = eye(n);

GENERAL INFORMATION Matlab is case sensitive so "a" and "A" are two different names. Comment statements are preceded by a "%". On-line help for MATLAB can be reached by typing help for the full menu or typing help followed by a particular function name. The commands who and whos give the names of the variables that have been defined in the workspace. The command length(x) returns the length of a vector x and size(x) returns the dimension of the matrix x.

CREATING FUNCTIONS As example of an M-file that defines a function, create a file in your working directory named yplusx.m that contains the following commands: function z = yplusx(y,x) z = y + x;

USING THE FUNCTIONS The following commands typed from within MATLAB demonstrate how this M-file is used: x = 2; y = 3; z = yplusx(y,x)

PLOTTING plot xlabel ylabel title grid axis stem subplot

EXAMPLE OF A PLOT Z = [0 : pi/50 : 10*pi]; X = exp(-.2.*Z).*cos(Z); Y = exp(-.2.*Z).*sin(Z); plot3(X,Y,Z); grid on; xlabel('x-axis'); ylabel('y-axis'); zlabel('z- axis');

Continuous Time System Analysis Transfer Function Representation Time Simulations Frequency Response Plots Control Design State Space Representation

Transfer Function Representation Tf2zp Zp2tf Cloop Feedback Parallel series

Cont… Transfer functions are defined in MATLAB by storing the coefficients of the numerator and the denominator in vectors. Given a continuous-time transfer function B(s) H(s) = A(s)

Cont… Where B(s) = b M s M +b M-1 s M-1 +…+b 0 and A(s) = a N s N +a N-1 s N-1 +…+a 0 Store the coefficients of B(s) and A(s) in the vectors num = [b M b M-1 … b 0 ] den = [a N a N-1 … a 0 ]

Example 5s+6 H(s) = s 3 +10s 2 +5 num = [5 6]; den = [ ]; all coefficients must be included in the vector, even zero coefficients

Cont… To find the zeros, poles and gain of a transfer function from the vectors num and den which contain the coefficients of the numerator and denominator polynomials: [z,p,k] = tf2zp (num,den)

Example num = [5 6]; den = [ ]; [z,p,k] = tf2zp (num,den) z = p = i i k = 5

Example Cont… (s-z 1 )(s-z 2 )...(s-z n ) H(s) = K (s-p 1 )(s-p 2 )...(s-p n ) 5*(s+1.2) (s )(s-{ i})(s-{ i})

Cont… To find the numerator and denominator polynomials from z, p, and k: [num,den] = zp2tf (z,p,k) To reduce the general feedback system to a single transfer function: T(s) = G(s)/(1+G(s)H(s)) [numT,denT]=feedback(numG,denG,numH,denH);

Cont… For a unity feedback system: [numT,denT] = cloop(numG,denG,-1); To reduce the series system to a single transfer function, T(s) = G(s)H(s) [numT,denT] = series(numG,denG,numH,denH); To reduce the parallel system to a single transfer function, T(s) = G(s) + H(s) [numT,denT] = parallel(numG,denG,numH,denH);

Example [num,den] = zp2tf (z,p,k) num = den =

Time Simulations residue Step Impulse lsim

Cont… [R,P,K] = residue (B,A) finds the residues, poles and direct term of a partial fraction expansion of the ratio of two polynomials B(s)/A(s) The residues are stored in r, the corresponding poles are stored in p, and the gain is stored in k.

Example If the ratio of two polynomials is expressed as b(s) 5s 3 +3s 2 -2s = a(s) -4s 3 +8s+3 b = [ ] a = [ ]

Example Cont… r = p = k = B(s) R(1) R(2) R(n) = K(s) A(s) s - P(1) s - P(2) s - P(n)

Find the response of a system to a particular input First store the numerator and denominator of the transfer function in num and den, respectively. To plot the step response: step(num,den) To plot the impulse response: impulse(num,den)

Cont… For the response to an arbitrary input, use the command lsim (linear simulation) Create a vector t which contains the time values in seconds t = a:b:c; Define the input x as a function of time, for example, a ramp is defined as x = t lsim(num,den,x,t);

Frequency Response Plots Freqs Bode Logspace Log10 Semilogx

Cont… To compute the frequency response H of a transfer function, store the numerator and denominator of the transfer function in the vectors num and den. Define a vector w that contains the frequencies for which H) is to be computed, for example w = a:b:c where a is the lowest frequency, c is the highest frequency and b is the increment in frequency. H = freqs(num,den,w)

Cont… To draw a Bode plot of a transfer function which has been stored in the vectors num and den: bode(num,den)

Cont… To customize the plot, first define the vector w which contains the frequencies at which the Bode plot will be calculated. Since w should be defined on a log scale, the command logspace is used. For example, to make a Bode plot ranging in frequencies from 0.1 to 100, define w by w = logspace(-1,2); The magnitude and phase information for the Bode plot can then be found by: [mag,phase] = bode(num,den,w);

Cont… To plot the magnitude in decibels, convert mag using the following command: magdb = 20*log10(mag); To plot the results on a semilog scale where the y- axis is linear and the x-axis is logarithmic: semilogx(w,magdb) For the log-magnitude plot : semilogx(w,phase)

Control Design Rlocus Consider a feedback loop where G(s)H(s) = KP(s) and K is a gain and P(s) contains the poles and zeros of the controller and of the plant. Suppose that the numerator and denominator coefficients of P(s) are stored in the vectors num and den. rlocus(num,den)

State Space Representation Ss Step Lsim Ss2tf Tf2ss ss2ss