EECE 360/460 Matlab Tutorial Jan 2011. Outline What is Matlab? What is Matlab? Matlab Interface Matlab Interface Basic Syntax Basic Syntax Plotting Graphs.

Slides:



Advertisements
Similar presentations
Introduction to Graphing Using MATLAB. Line Graphs  Useful for graphing functions  Useful for displaying data trends over time  Useful for showing.
Advertisements

Introduction to Matlab EE 2303 Lab. MATLAB stands for “Matrix Laboratory” APPLICATIONS OF MATLAB:  Mathematical Calculations  Data Analysis & Visualization.
Introduction to Matlab. I use Matlab for: Data analysis Data plotting Image Analysis Also – Simulations (solving odes/pdes/finite element methods) – Minimisations,
Welcome to EGR 106 Foundations of Engineering II Course information Today’s specific topics: – Computation and algorithms – M ATLAB Basics Demonstrations.
Introduction to MATLAB
Introduction to Matlab Tutorial for CS4MN3/SE3X03 Wen Yu McMaster University.
1 ECEN Automatic Control Systems Matlab Lecture 1 Introduction and Control Basics Presented by Moayed Daneshyari OKLAHOMA STATE UNIVERSITY.
Introduction to Matlab 332:202 Discrete Mathematics Spring 2007.
Introduction to Matlab Jianguo Wang CSSCR September 2009.
Introduction to MATLAB ENGR 1187 MATLAB 1. Programming In The Real World Programming is a powerful tool for solving problems in every day industry settings.
Digital Image Processing Lecture3: Introduction to MATLAB.
MATLAB and SimulinkLecture 11 To days Outline  Introduction  MATLAB Desktop  Basic Features  Branching Statements  Loops  Script file / Commando.
259 Lecture 15 Introduction to MATLAB. 2 What is MATLAB?  MATLAB, which stands for “MATrix LABoratory” is a high- performance language for technical.
Martin Ellison University of Warwick and CEPR Bank of England, December 2005 Introduction to MATLAB.
MATLAB Tutorials Session I Introduction to MATLAB Rajeev Madazhy Dept of Mechanical Engineering LSU.
Introduction to Matlab 1. Outline: What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators Plotting Flow Control Using of M-File Writing.
„  1999 BG Mobasseri1 9/18/2015 June 2 GRAPHICS IN MATLAB- PART I BASIC PLOTTING.
Lecture 4 MATLAB Windows Arithmetic Operators Maintenance Functions
Objectives Understand what MATLAB is and why it is widely used in engineering and science Start the MATLAB program and solve simple problems in the command.
ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1.
1 Lab of COMP 406 Teaching Assistant: Pei-Yuan Zhou Contact: Lab 1: 12 Sep., 2014 Introduction of Matlab (I)
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
ENG 1181 College of Engineering Engineering Education Innovation Center MATLAB is a powerful program for numerical computations, plotting and programming.
Introduction to MATLAB ENGR 1181 MATLAB 1. Programming In The Real World Programming is a powerful tool for solving problems in every day industry settings.
Introduction to Engineering MATLAB – 1 Introduction to MATLAB Agenda Introduction Arithmetic Operations MATLAB Windows Command Window Defining Variables.
Matlab Workshop 1/10/07 Lesson 1: Matlab as a graphing calculator.
MATLAB Tutorial EE 327 Signals and Systems 1. What is MATLAB? MATLAB – Matrix Laboratory The premier number-crunching software Extremely useful for signal.
INTRODUCTION TO MATLAB LAB# 01
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (1): Introduction.
Matlab Basics Tutorial. Vectors Let's start off by creating something simple, like a vector. Enter each element of the vector (separated by a space) between.
What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation tools. Others include Maple Mathematica MathCad.
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
Introduction to Engineering MATLAB – 2 Introduction to MATLAB - 2 Agenda Defining Variables MATLAB Windows.
MATLAB Environment ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne.
Lecture 2 - Matlab Introduction CVEN 302 June 5, 2002.
Matlab 14.html Cost: $100 Available in labs on Windows and Unix machines.
Introduction to MATLAB ENGR 1181 MATLAB 1. Opening MATLAB  Students, please open MATLAB now.  CLICK on the shortcut icon → Alternatively, select… start/All.
Chapter 3 MATLAB Fundamentals Introduction to MATLAB Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
1 DKT 211 Basic Communication Engineering LAB # 1A : (Lecture 1) Introduction to Matlab  Basic Features  Scientific features  Array Operations  Script.
Matlab Screen  Command Window  type commands  Current Directory  View folders and m-files  Workspace  View program variables  Double click on a.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
MATLAB Tutorial EE313 Signals and Systems Created: Thursday Jan 25, 2007 Rayyan Jaber Modified by: Jeff Andrews.
Recap Chapter 5 “Plotting” Two Dimensional Plots Simple x-y Plots Titles, Labels and Grids Multiple Plots.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
Interduction to MATLAB Manal Alotaibi Mathematics department College of science King saud university.
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
ENG 1181 First-Year Engineering Program College of Engineering Engineering Education Innovation Center First-Year Engineering Program MAT - Introduction.
Introduction to Matlab
Today we will learn MATLAB Click Start  All programm  Class Software  Matlab This command window will be seen with a prompt sign >> Any command can.
1 Lecture 5 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
ECE 351 M ATLAB I NTRODUCTION ( BY T EACHING A SSISTANTS )
Program design and algorithm development We will consider the design of your own toolbox to be included among the toolboxes already available with your.
MATLAB Lecture 1 염익준. Introduction MATLAB (MATrix LABoratory) a special purpose computer program optimized to perform engineering and scientific calculations.
1 Faculty Name Prof. A. A. Saati. 2 MATLAB Fundamentals 3 1.Reading home works ( Applied Numerical Methods )  CHAPTER 2: MATLAB Fundamentals (p.24)
Introduction to MATLAB ENGR 1181 MATLAB 1. MATLAB Built-in Math Functions  Pre-defined in MATLAB ready for use exp(x) – exponential (e x ) log(x) – natural.
Introduction to Programming on MATLAB Ecological Modeling Course Sep 11th, 2006.
Structured Computer Programming EE 201 Introduction to MATLAB 7 for Engineers بسم الله الرحمن الرحيم King Abdulaziz University College of Engineering Dept.
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
NoViC, Dept. of Mechanical Eng Acoustics Lab., NoViC 1. Download Matlab 2.
How to use MATLAB (using M-files) Double click this icon To start Matlab 6.5.
Introduction to MATLAB
INTRODUCTION TO BASIC MATLAB
MATLAB DENC 2533 ECADD LAB 9.
MATLAB How to use (using M-files) Double click this icon
Use of Mathematics using Technology (Maltlab)
MATLAB How to use (using M-files) Double click this icon
MATLAB How to use (using M-files)
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
Introduction to Matlab
Matlab Basics Tutorial
Presentation transcript:

EECE 360/460 Matlab Tutorial Jan 2011

Outline What is Matlab? What is Matlab? Matlab Interface Matlab Interface Basic Syntax Basic Syntax Plotting Graphs Plotting Graphs Control System Toolbox Control System Toolbox Examples Examples Useful Resources Useful Resources

Overview of Matlab

What is Matlab? Language for technical computing Language for technical computing Supports mathematical computation, visualization, and programming Supports mathematical computation, visualization, and programming Composed using high-level programming language Composed using high-level programming language similar to syntax of C similar to syntax of C For EECE 360 For EECE 360 Use Matlab in the assignments Use Matlab in the assignments

Matlab Interface

Command Window Workspace Command History Change the current directory to the location of your Matlab file at startup

Matlab Programming Two Approaches Two Approaches Coding in Command Window Coding in Command Window Good for short programs Good for short programs Commands must be re-entered each time you run a simulation Commands must be re-entered each time you run a simulation Coding with.m-files Coding with.m-files Good for long programs Good for long programs Allows users to save all the commands written in the.m-files Allows users to save all the commands written in the.m-files

Command Window Interface Write your commands here

(1) Creating.m-files File  New  M- File (2) Opening.m-files File  Open  select the.m-file

.m-file Interface Write your commands here To run the program, press F5

Workspace Interface The workspace provides a summary of the variables The workspace provides a summary of the variables

Command History Interface The Command History stores all the commands entered in the Command Window previously The Command History stores all the commands entered in the Command Window previously No history of.m-files is shown here No history of.m-files is shown here

Syntax Errors All errors are given in the Command Window in red All errors are given in the Command Window in red Nature of error is explained Nature of error is explained

Examples on Matlab Interface

Basic Syntax

Assignment of Variables Assignment of Variables Syntax: Variable = Expression Syntax: Variable = Expression Example: A = 1; Example: A = 1; Use of semi-colons Use of semi-colons With semi-colon – suppress output With semi-colon – suppress output Without semi-colon – displays output in command window Without semi-colon – displays output in command window Adding comments Adding comments Add % before command line Add % before command line Example: % This is a demo Example: % This is a demo

Basic Syntax (cont’d) Step increment Step increment Example: k = 1:0.1:10 Example: k = 1:0.1:10 k is a row-matrix from 1 to 10 with step size = 0.1 k is a row-matrix from 1 to 10 with step size = 0.1 Matrix Expression Matrix Expression Hence, for a 2x2 matrix, the syntax is Hence, for a 2x2 matrix, the syntax is A = [1 2; 3 4] A = [1 2; 3 4] Row-matrixColumn-matrix

Basic Syntax (cont’d) Mathematical (Array) Operators Mathematical (Array) Operators Note the dimension of matrix in matrix computation Note the dimension of matrix in matrix computation Example: A: 2x1 matrix, B: 2x2 matrix Example: A: 2x1 matrix, B: 2x2 matrix A*B  invalid operation B*A  valid operation +Addition -Subtraction *Multiplication /Division ^Power Mathematical+Addition-Subtraction.*Multiplication./Division.^Power Mathematical Array

Basic Syntax (cont’d) Common Built-in Math Functions Common Built-in Math Functions sin(x) - sine sin(x) - sine cos(x) - cosine cos(x) - cosine tan(x) - tangent tan(x) - tangent exp(x) - exponential exp(x) - exponential log10(x) – base10 logarithm log10(x) – base10 logarithm sqrt(x) – square root sqrt(x) – square root abs(x) – absolute value abs(x) – absolute value The complete list can be found on pp. 833 of text The complete list can be found on pp. 833 of text

Examples on Basic Syntax

Plotting Graphs

Matlab allows graphical displays Matlab allows graphical displays By using the command plot By using the command plot Syntax: plot(x) Syntax: plot(x) Types of plots Types of plots Syntax: plot(x,’-’) Syntax: plot(x,’-’) - Solid line -- Dashed line : Dotted line -. Dashdot line

Plotting Graphs (cont’d) Labeling Graphs Labeling Graphs Commonly used Syntax: Commonly used Syntax: ylabel(‘text’) – label y-axis ylabel(‘text’) – label y-axis xlabel(‘text’) – label x-axis xlabel(‘text’) – label x-axis title(‘text’) – label title title(‘text’) – label title legend(‘legend1’, ‘length2’,…) – puts legend on current plot legend(‘legend1’, ‘length2’,…) – puts legend on current plot grid on (grid off) – add (remove) grid lines to figure grid on (grid off) – add (remove) grid lines to figure subplot – subdivides graphic window subplot – subdivides graphic window hold on – hold the previous plot on the graphic window hold on – hold the previous plot on the graphic window

Example (1)

Example (2) subplot(2,2,1) plot(x,’r’),hold on plot(y,’--’) subplot(2,2,2) plot(x,’r’),hold on plot(y,’--’) subplot(2,2,3) plot(x,’r’),hold on plot(y,’--’) subplot(2,2,4) plot(x,’r’),hold on plot(y,’--’)

Examples on Plotting Graphs

Control System Toolbox

Overview to the Toolbox Modeled control systems as Modeled control systems as (1) transfer functions (2) zero-pole-gain (3) state-space form Can manipulate both Can manipulate both (1) continuous-time system (2) discrete-time system Can compute and graph Can compute and graph (1) time response (2) frequency response

Demo (1) Transfer Function Transfer Function Syntax: tf(numerator, denomintor) Syntax: tf(numerator, denomintor)

Demo (2) State-space Representation State-space Representation Syntax: sys_ss = ss(sys) Syntax: sys_ss = ss(sys)

Demo (3) Finding Poles and Zeros Finding Poles and Zeros Syntax: z = zero(sys) Syntax: z = zero(sys) p = pole(sys) p = pole(sys) Pole-Zero Diagram Pole-Zero Diagram Syntax: zplane(z,p) Syntax: zplane(z,p)

Demo (4) Closed-Loop System Closed-Loop System Syntax: CLsys = feedback(sys1,sys2) Syntax: CLsys = feedback(sys1,sys2) System 1 System 2 + -

Demo (5) Step Response Step Response Syntax: step(sys) Syntax: step(sys)

Demo (6) Pole-zero cancellation Pole-zero cancellation Syntax: sysr = minreal(sys); Syntax: sysr = minreal(sys); Impulse Response Impulse Response Syntax: impulse(sys) Syntax: impulse(sys)

Examples on Control System Toolbox

Useful Resources Appendix A of Textbook Appendix A of Textbook End of Chapter – Matlab Demo End of Chapter – Matlab Demo