Note 10 Introduction to MATLAB & SIMULINK

Similar documents
Guidelines for MATLAB s SISO Design Tool GUI

Lecture 15 Nyquist Criterion and Diagram

INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX

Session 3 Introduction to SIMULINK

Control System Toolbox

Using MATLAB, SIMULINK and Control System Toolbox

Root Locus Controller Design

Introduction to the MATLAB SIMULINK Program

2. Introduction to Matlab Control System Toolbox

Lab # 3 Time Response Design. State Space and Transfer Functions

MATLAB CONTROL SYSTEM TOOLBOX IN LTI SYSTEM MODEL ANALYSIS

Workshop Matlab/Simulink in Drives and Power electronics Lecture 3

Introduction to Simulink

Simulink Basics Tutorial

Simulink Basics Tutorial

SIMULINK Tutorial. Select File-New-Model from the menu bar of this window. The following window should now appear.

Lab # 8 Parallel Port Interface with LabView & Root Locus Design

Introduction to Matlab Simulink. Control Systems

BRUSH UP ON MATLAB UNIVERSITY OF PAVIA. Industrial Control FACULTY OF ENGINEERING. Prof. Lalo Magni

ME422 Mechanical Control Systems Matlab/Simulink Hints and Tips

An Introduction to MATLAB and the Control Systems toolbox Aravind Parchuri, Darren Hon and Albert Honein

Lab 7: PID Control with Trajectory Following

Introduction to Simulink

SPA_GUI. Matlab graphical user interface allowing signal processing and. variable selection for multivariate calibration.

ELEC4042 Signal Processing 2 MATLAB Review (prepared by A/Prof Ambikairajah)

MATLAB Premier. Middle East Technical University Department of Mechanical Engineering ME 304 1/50

Experiment 6 SIMULINK

UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER

Process Automation CHEM-E7140

Developing a MATLAB-Based Control System Design and Analysis Tool for Enhanced Learning Environment in Control System Education

SIMULINK A Tutorial by Tom Nguyen

Experiment 8 SIMULINK

2.0 MATLAB Fundamentals

Matlab Programming MET 164 1/24

Inlichtingenblad, matlab- en simulink handleiding en practicumopgaven IWS

MATLAB Control Software Bharat Balagopal, Bharathram Balasubramanian, and Eric Stratton Green

SIGNALS AND LINEAR SYSTEMS LABORATORY EELE

[ MATLAB ] [ Resources ] PART TWO: SIMULINK

16.06/16.07 Matlab/Simulink Tutorial

Here is a quick introduction to Matlab and a couple of its symbolic and control functions.

ELEC ENG 4CL4 CONTROL SYSTEM DESIGN

Example: Modeling a Cruise Control System in Simulink

User Defined Functions

3 An Introductory Demonstration Execute the following command to view a quick introduction to Matlab. >> intro (Use your mouse to position windows on

E105: RLTOOL Tutorial

BME 5742 Bio-Systems Modeling and Control

LEARNING TO PROGRAM WITH MATLAB. Building GUI Tools. Wiley. University of Notre Dame. Craig S. Lent Department of Electrical Engineering

Experiment # 5. Introduction to Error Control Codes

Matlab notes Matlab is a matrix-based, high-performance language for technical computing It integrates computation, visualisation and programming usin

Control System Toolbox For Use with MATLAB

Control System Toolbox For Use with MATLAB

American International University- Bangladesh Faculty of Engineering (EEE) Control Systems Laboratory

Inlichtingenblad, matlab- en simulink handleiding en practicumopgaven IWS

UNIT 5. Simulink. 1. Introduction

Lab. Manual. Practical Special Topics (Matlab Programming) (EngE416) Prepared By Dr. Emad Saeid

MATLAB MATLAB mat lab funtool

Login your clickers & NO calculators. Get the 4.1 checkpoint from the brown table and answer the questions.

2 SIMULATING A MODEL Simulink Tutorial

Introduction to programming in MATLAB

Menu-driven Graphical Interface for MATLAB Control Design*

Introduction to Scientific Computing with Matlab

MATLAB BASICS. < Any system: Enter quit at Matlab prompt < PC/Windows: Close command window < To interrupt execution: Enter Ctrl-c.

FLORIDA INTERNATIONAL UNIVERSITY EEL-6681 FUZZY SYSTEMS

MATLAB 7. The Language of Technical Computing KEY FEATURES

Contents RELEASE AND UPGRADE NOTES. Version 4.0

Nonlinear Control(FRTN05)

Introduction to MATLAB

How to Use MATLAB. What is MATLAB. Getting Started. Online Help. General Purpose Commands

MATLAB Basics. Configure a MATLAB Package 6/7/2017. Stanley Liang, PhD York University. Get a MATLAB Student License on Matworks

FDP on Electronic Design Tools Matlab for Control System Modeling 13/12/2017. A hands-on training session on

University of Alberta

Appendix B: MATLAB Tutorial

Signals and Systems INTRODUCTION TO MATLAB Fall Thomas F. Weiss

Introduction to Simulink. The Use of Mathematic Simulations in Electrical Engineering

The MATLAB system The MATLAB system consists of five main parts:

Introduction to MATLAB

Matlab Advanced Programming. Matt Wyant University of Washington

MATLAB Premier. Asst. Prof. Dr. Melik DÖLEN. Middle East Technical University Department of Mechanical Engineering 10/30/04 ME 304 1

Text box. Command button. 1. Click the tool for the control you choose to draw in this case, the text box.

Prof. Manoochehr Shirzaei. RaTlab.asu.edu

A Brief Introduction to MATLAB Evans Library Research Support Workshops

MATLAB. Miran H. S. Mohammed. Lecture 1

MATLAB is a multi-paradigm numerical computing environment fourth-generation programming language. A proprietary programming language developed by

What is Simulink. >>simulink

Introduction to Scientific Computing with Matlab

Introduction to Simulink

Control System Toolbox

UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER

ME2142/ME2142E Feedback Control Systems

MATLAB INTRODUCTION. Risk analysis lab Ceffer Attila. PhD student BUTE Department Of Networked Systems and Services

Module 4. Computer-Aided Design (CAD) systems

Computer Aided Design (CAD) Lecture 10. Introduction to Simulink (3) Dr.Eng. Basem ElHalawany

SIMULINK FOR BEGINNERS:

Matlab Tutorial, CDS

Exercises Unit 4. Graphics User Interface

Getting Started with MATLAB

Colorado State University Department of Mechanical Engineering. MECH Laboratory Exercise #1 Introduction to MATLAB

Version USER GUIDE A Matlab Graphical User Interface for Flight Dynamics Analysis

ME scope Application Note 19

LAB 1 General MATLAB Information 1

Transcription:

Note 10 Introduction to MATLAB & SIMULINK Department of Mechanical Engineering, University Of Saskatchewan, 57 Campus Drive, Saskatoon, SK S7N 5A9, Canada 1

1 Introduction to MATLAB MATLAB stands for the matrix laboratory It is an easy-to-use programming environment for performing numerical computation and graphically displaying the results It was first designed to perform matrix computation in 1960 Since then MATLAB has been developed being very powerful and has been widely used in many different engineering fields as well as scientific and non-scientific areas When used with routines from its companion software, the Control System Toolbox, MATLAB can be used to analyze and design control system problems such as those covered in our class 11 MATLAB Variables In MATLAB, variables are used to store various types of data such as scalars, vectors, matrices, etc MATLAB variables are created when they are assigned values For example, enter the following commands in the Command Window, >> x=150 % Assign 150 to x and display >> P1=[1 3 17] % Assign the vector of [1 3 17] to P and display (using a space between any % two elements) >> P=[1 0 3]; % The command ending with ; causes MATLAB not to display the result In MATLAB, % is used to indicate comments followed, which will not be executed by MATLAB Once the above commends are executed in MATLAB, the names of three variables, ie, x, P1, and P and their values are saved in a part of computer memory, called the Workspace in MATLAB You may use >> who % List all variables in the workspace >> x % Enter the name of a variable to display its value >> clear % Remove all variables and their values from the workspace In addition, you may use >> clc % Clear command window 1 Common Commands or Functions used in Control Systems A command (also referred to a function) is an instruction for a computer to perform a specific operation Create Polynomials >> P=[1 7-3 3] % Create a polynomial: P = s 3 + 7s 3s + 3 % The vector contains the coefficients of the polynomial Department of Mechanical Engineering, University Of Saskatchewan, 57 Campus Drive, Saskatoon, SK S7N 5A9, Canada

>> P=poly([- -5-6]) % Create a polynomial: P = ( s + )( s + 5)( s + 6) % The vector in poly () contains the roots of the polynomial >> P=conv([1 7], [1-3 ]) % Create a polynomial: P = ( s + 7)( s 3s + ) % The two vectors in conv() contains the coefficients of the two polynomials % respectively Create Transfer Function - using the function tf (, ) Using the following three commands to generate a transfer function s + G ( s) s + 3s + 16 >> numf=[1 ] % Create a polynomial: numf = s + >> denf=[1 3 16] % Create a polynomial: denf = s + 3s + 16 >> G1=tf(numf, denf) % Create a transfer function G1 % The first argument in tf() defines the numerator of the transfer function and % the second one defines its denominator Using the following three commands to generate a transfer function >> numf=[1 ]] % Create a polynomial: numf = s + >> denf=poly([-1-5]) % Create a polynomial: denf = ( s + 1)( s + 5) >> G=tf(numf, denf) % Create a transfer function G s + G ( s) ( s + 1)( s + 5) Find the closed-loop transfer function - by using the function feedback (, ) >> numf=[5]] % Create a polynomial: >> denf=poly([0-5]) % Create a polynomial: >> G=tf(numf, denf) % Create a transfer function G(s) >> T=feedback(G, 1) % Find the closed-loop transfer function T(s) Time Response using the function step( ) 16 Using the following commands to plot the step response of the system G ( s) s + 3s + 16 >> numf=[16] % Create a polynomial: numf = 16 >> denf=[1 3 16] % Create a polynomial: denf = s + 3s + 16 >> G=tf(numf, denf) % Create a transfer function G >> step (G) % Plot the step response, which is displayed in the widow of Figure >> grid on % Adds major grid lines to the axes Department of Mechanical Engineering, University Of Saskatchewan, 57 Campus Drive, Saskatoon, SK S7N 5A9, Canada 3

Find the poles of a system (then determine its stability) - by using the function pole() >> pole(g); % Compute the poles of the system defined by G Draw the Bode plots - by using the function bode ( ) >> bode(g) % Draw the Bode plot of the system defined by G >> grid on % Turn on grid for Bode plot, ie, adds major grid lines to the axes Draw Root locus - by using the function rlocus( ) Using the following commands to draw the root locus for K( s 3)( s 5) KGH = ( s + 1)( s + ) >> numf=poly([3 5]) % Create a polynomial: numf = ( s 3)( s 5) >> denf=poly([-1 -]) % Create a polynomial: denf = ( s + 1)( s + ) >> GH=tf(numf, denf) % Create the open-loop transfer function GH >> rlocus (GH) % Draw the root locus, which is displayed in the widow of Figure >> grid on % Adds major grid lines to the axes 13 M-files Using the Command Window to solve problems by entering and executing individual MATLAB command can be a tedious process, especially if the same or a similar set of commands have to be entered a number of times An alternative approach for executing multiple commands is to use a MATLAB M-file A MATLAB M-file is a file that contains a series of Matlab commands The file is generated using the MATLAB Editor(enter the command edit in the Command Window to get such a Editor); and the commands in the file are executed by selecting Run under the Debug menu in the MATLAB Editor, or entering the name of the file in the Command Window For example, the following is an example of MATLAB M-file % This program is used to plot the step response of a system numf=[16]; % Create the numerator polynomial denf=[1 3 16]; % Create the denominator polynomial G=tf(numf, denf); % Create a transfer function G step (G); % Plot the step response grid on; % Adds major grid lines to the axes % The End Department of Mechanical Engineering, University Of Saskatchewan, 57 Campus Drive, Saskatoon, SK S7N 5A9, Canada 4

SIMULINK SIMULINK, a companion program to MATLAB, is a software package for modeling, simulating, and analyzing dynamic systems In SIMULINK, you can use the graphical user interface (GUI) to generate your dynamic or control system, and then run a simulation for the system The procedure of using SIMULINK is described as follows (1) Starting SIMULINK Entering the command simulink in the Command Window, then you will see the SIMULINK Library Brower () Create a New Model In the SIMULINK Library Brower, click on the button of Create a new model, you will have a window to create a model Then, Drag the required blocks to your mode window from the SIMULINK Library Brower A block is used to perform a specific function; and the SIMULINK Library Brower can provide all kinds of blocks, which are organized in different categories such as Continuous (ie, subsystems), Sources (ie, function generators), and Sinks (ie, scopes), etc Quite often, you may need to choose the parameters for a block in your model To do that, Double-click the block and type in the desired parameters Interconnect the blocks by drawing lines Position the pointer over the first block s output port, press the mouse button, and drag the pointer to the second s input pot Please note: to draw a branch line from an existing line, you need to hold down the key of Ctrl (3) Run a Simulation for the Model In your model window, select Start under the Simulation menu Sometimes, you may need to choose the parameter for a simulation, such as simulation time To do that, select Configuration Parameters under the Simulation menu in your model window and set the desired parameters (4) Viewing the Simulation Results Double-click the Scope block in you model to view the simulation results For this purpose, when you create your model you need to drag a Scope block from the SIMULINK Library Brower and to connect it the output of the system, which you want to view the simulation results Examples of using SIMULINK by following the above procedure will be illustrated in class Department of Mechanical Engineering, University Of Saskatchewan, 57 Campus Drive, Saskatoon, SK S7N 5A9, Canada 5