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

Size: px
Start display at page:

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

Transcription

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

2 Outline Introduction Basic Features of MATLAB Prompt Level and Basic Arithmetic Operations Scalars, Vectors, and Matrices Matrix Operations and MATLAB Functions Graphics and Data Visualization Programming in MATLAB MATLAB in Control Engineering Operations on Transfer Functions Simulation of LTI Systems Simulink ME 304 /50

3 Introduction MATrix LABoratory MATLAB is an interactive software for numerical / symbolic computations and graphics. Originally designed for matrix computations, solving linear equation sets, data visualization,, etc. The capabilities of MATLAB can be extended through programs written in its own programming language called M-script script. Over the years, the capabilities of MATLAB in every aspect have widened rapidly. It has now become an industry-standard standard computing environment and an outstanding tool for engineering education. ME 304 3/50

4 MATLAB Prompt To get started, type one of these: helpwin, helpdesk, or demo. For product information, type tour or visit (45 + 7)/3 ans = Arithmetic operations: +, -, *, /, ^ ans (ANSwer) is a temporary variable storing the result of an instant calculation.» 100^ 3.5*ans Previous answer can be recalled. ans = e+004 Scientific notation: » sqrt(ans) MATLAB offers a large number of predefined ans = functions like sqrt, sin, cos, tan, exp, log, atan, abs, tanh, and more... ME 304 4/50

5 MATLAB Objects» a =.1 a =.100» b = -9.75;» x = [1; ; 3] x = 1 3» y = [1 3] y = 1 3 Result of various operations can be assigned to the variables you want to define. Variable names are case sensitive. Note that semicolon (;) suppresses the display. Column vector (3 1) is defined: x = 1 3 y is a row vector (1 3): y = [1 3] ME 304 5/50

6 MATLAB Objects (Cont d)» A = [1 3; 4 5 6; 7 8 9] A =» whos Name Size Bytes Class A 3x3 7 double array a 1x1 8 double array ans 1x1 8 double array b 1x1 8 double array x 3x1 4 double array y 1x3 4 double array A is a matrix (3 3): A = whos displays the names of all variables defined in the MATLAB workspace (memory). Grand total is 18 elements using 144 bytes ME 304 6/50

7 Special Variables» i ans =» -5 + a*i i ans = i» cos(pi) ans = -1» a = inf;» 1/a ans = 0 By default, i and j are defined as imaginary unit ( -1). MATLAB allows storage of complex numbers and relevant operations on them. cos(π) a = ME 304 7/50

8 Important Notes» sin(x) ans = » help ans Most arithmetic operators and certain functions work for matrices and vectors as well. An extensive online help is available. ANS Most recent answer. ANS is the variable created automatically when expressions are not assigned to anything else. ANSwer. ME 304 8/50

9 Array Manipulations» A(,3) ans = 6» A(:,) ans = 5 8» A(3,:) ans = 7 8 9» A(1:,:3) ans = Returns the element at nd row, 3rd column. Returns all the elements at nd column. Returns all the elements at 3rd row. Returns submatrix. Column 1 3 A = Row 1 3 ME 304 9/50

10 Array Manipulations (Cont d)» B = [A; zeros(1,3); y] B = Forms a new matrix B using the variables previously defined. Here, the command zeros(m,n) creates an (m by n) matrix consisting of 0 elements. 1 3 B = [A] 3x3 [0] 1x3 [y] 1x3 B = [ ] [ 1 3 ] Matrix A Zero vector Vector y ME /50

11 Array Manipulations (Cont d)» B = [x ones(3,1) A] B = Redefines matrix B using the variables previously defined. Here, the command ones(m,n) creates an (m by n) matrix consisting of 1s B = [x] 3x1 [1] 3x1 [A] 3x3 B = Vector x Unity vector Matrix A ME /50

12 Matrix Operations» A = [1 3; 4 5 6; 7 8 9];» B = [1 0; 4 0 6; 0 8 9];» C = [1 ; 3 4; 5 6];» C' ans = » det(a) ans = 0» inv(b) ans = Let us define these matrices. Matrix transpose using (') operator. The command transpose(c) serves for the same purpose. DETerminant of matrix A. INVerse of matrix B. ME 304 1/50

13 Matrix Operations (Cont d)» A+B ans = MATLAB enables you to perform arithmetic operations (+,-,*) on matrices.» A+C??? Error using ==> + Matrix dimensions must agree.» A*C ans = » C*A??? Error using ==> * Inner matrix dimensions must agree. Matrices must be conformable to carry out a certain operation. Matrix multiplication. Invalid operation due to a mismatch in matrix inner dimensions. ME /50

14 Matrix Operations (Cont d)» A-3 ans = » 3*A ans = » A.*B ans = Scalars (1 1) are exceptions in matrix operations. Multiplies every element of the matrix A by 3. Multiplies the corresponding elements of matrix A and B. The operator (.*) is called array multiplication. ME /50

15 Solving Equation Sets Consider this equation set: x x 5x x 3x 8x 4x 3 + x + 10x = = 1 = Alternatively, we have x = x x 10 x = 1 A x = Therefore, the solution becomes (A A) x = A b x = A b b To implement this in MATLAB, one defines the following:» A = [1 1-4; -3 ; ];» b = [8; 1; ];» x = A\b The operator (\) is called left matrix divide and it essentially solves the linear system using Gauss-Seidel method. Note that x = inv(a)*b yields the same result. ME /50

16 Advanced Matrix Functions» eig(a) Returns all the eigenvalues of matrix A. ans = » [V,D] = eig(a) V = Eigenvectors D = Eigenvalues lu (command) computes LU factorization of a matrix. chol computes the cholesky factorization of a symmetric positive definite matrix. qr computes the QR factorization of a matrix. svd obtains singular value decomposition of a matrix. norm computes various matrix or vector norms. cond, condest, rcond estimates various condition numbers. ME /50

17 Vectors» t = 1:5 t = » t = 0:.1:1 Creates a row vector whose components increase arithmetically. Components can change by non-unit steps. t = Columns 1 through Columns 8 through » t = linspace(0,1,11) Generates a vector with 11 equally spaced elements that lie between 0 and 1. t = Columns 1 through Columns 8 through ME /50

18 D Graphics MATLAB offers a wide variety of built-in in data visualization functions. Function plot is used to generate D graphs. To obtain a graph of y=f(x f(x), one needs to create the domain x and then form the range y with the corresponding function values.» x = linspace(0,*pi,100);» y = sin(x);» plot(x,y);» xlabel( x [rad] );» ylabel( y );» grid on; ME /50

19 D Graphics (Cont d) As the second example, let us plot the following function: x y = f (x) = 1+ x The corresponding MATLAB commands are as follows:» x = linspace(-5,5,100);» y = x./(1+x.*x);» plot(x,y);» xlabel( x );» ylabel( y );» grid on; ME /50

20 Programming Entering all the commands at the MATLAB prompt sequentially is a tedious and slow process. One can type in all the commands in a text file having an extension of m. The file containing these commands is called M-script. When the name of this m file is keyed in just like a command at the prompt, MATLAB executes all the commands sequentially. Similar to a high-level language, MATLAB provides a number of standard programming constructs such as loops and conditionals. ME 304 0/50

21 Conditionals IF Statement if <boolean expression 1> MATLAB statements elseif <boolean expression > MATLAB statements else MATLAB statements end Example if x == 0 y = 0; elseif x == 1 y = 1; else y = 1 *(x.5); end The use of conditionals in MATLAB programs are very similar to those of common high-level languages. The logical operators in MATLAB are <, >, <=, >=, == (logical equal), ~= (not equal). Boolean expressions take the values 1 (true) or 0 (false). ME 304 1/50

22 For Loop FOR Statement for variable = expression MATLAB statements end Example 1 for k = 1:4 disp(k); end Example for k = [ ] disp(k); end for loop repeats the statements as the loop index takes on the values in a given vector. Like an if construct, the loop must be terminated by end statement. disp command simply displays its argument without showing the variable name. ME 304 /50

23 While Loop WHILE Statement while <boolean expression> MATLAB statements end Example x = 1; while 1+x > 1 x = x/; end disp(*x) Output.04e-016 while loop repeats the statements as long as the given boolean expression is true. Another important command is break which terminates the current for or while loop. The sample program is used to test the floating point accuracy ( machine( epsilon ) ) of a particular computer system. ME 304 3/50

24 MATLAB Functions While programming, it is often times necessary to define one s own subroutines (procedures/functions). Unlike high-level languages, these functions cannot be included in the main program. Each function has to be an individual m file. This m file that begins with a line of the following form: function [out1,out,...] = cmd_name(in1,in,...) When a function is invoked, MATLAB creates a temporary workspace. The statements inside the function have no access to the variables used in the main workspace unless they are passed as inputs. When execution ends, all local variables are erased. ME 304 4/50

25 MATLAB Functions (Cont d) function [y,z] = fcn(x) z = 1 + x.*x; y = x./z; plot(x,y) M-file named fcn.m.» x = linspace(-5,5,100);» fcn(x) Calls M-file named fcn.m and passes the vector x.» y1 = fcn(x);» [y,z] = fcn(x); Different output arguments were passed from the MATLAB function fcn. ME 304 5/50

26 Useful MATLAB Functions Poles of a System D(s) = s 5 + 3s 4 + 7s 3 + 5s» den = [ ];» roots(den) ans = i i i i + s + 1 Characteristic Polynomial Let the poles of a system be p 1 = -3; p = -; p 3 = -1; p 3,4 = -5 ± 5i;» poles = [ *i 5-5*i];» poly(poles) ans = The resulting characteristic polynomial is D(s) = s s s s + 610s ME 304 6/50

27 Useful Commands (Cont d) Partial Fractions Expansion» num = [ 5 3 6];» den = [ ];» [r,p,k] = residue(num,den) Consider the following TF: G(s) s s s + 6s + 3s s + 6 r = = Residues The resulting fractions are G(s) = N i= 1 ri s p i + k G (s) = s + 3 s + s + 1 p = k = Poles Remainder ME 304 7/50

28 Useful Commands (Cont d) Polynomial Multiplication 3 P(s) = s + s + 3s + 1 D(s) = P(s)Q(s) =? Q(s) = s + s + 5 Zero/Pole Locations» num = [ 5 3 6];» den = [ ];» pzmap(num,den)» P = [1 3 1];» Q = [1 1 5];» D = conv(p,q) D = Pole-Zero Map The resulting polynomial becomes Imag Axis D(s) = s 5 + 3s s s + 16s Real Axis ME 304 8/50

29 Block Diagram Reduction Transfer Functions in Series X(s) G 1 (s) Y(s) X(s) = G(s) = G As an illustration, let G (s) 1 (s)g (s) Y(s)» num1 = [1 5]; den1 = [1 3 5];» num = [1]; den = [1 1];» [num,den] = series(num1,den1,num,den) num = den = The resulting TF becomes s + 5 G1(s) = ; G(s) = s + 3s s + 1 G(s) = s 3 + 4s s s + 5 NUMerator DENominator ME 304 9/50

30 BD Reduction (Cont d) Transfer Functions in Parallel G 1 (s)» num1 = [1 5]; den1 = [1 3 5];» num = [1]; den = [1 1];» [num,den]=parallel(num1,den1,num,den) X(s) + Y(s) num = G (s) Y(s) X(s) = G(s) = G1 (s) + G As an illustration, let (s) den = The resulting TF becomes s + 5 G1(s) = ; G(s) = s + 3s s + 1 G(s) = s 3 s + 4s + 9s s + 5 ME /50

31 BD Reduction (Cont d) Closed Loop Transfer Functions X(s) + Y(s) X(s) _ G 1 (s) G (s) G (s) = G(s) = 1 1+ G (s)g As an illustration, let 1 (s) Y(s)» num1 = [1 5]; den1 = [1 3 5];» num = [1]; den = [1 1];» [num,den]=feedback(num1,den1,num,den) num = den = The resulting TF becomes s + 5 G1(s) = ; G(s) = s + 3s s + 1 G(s) = s 3 s + 4s + 6s s + 10 ME /50

32 Unit Impulse Response As an illustration, let G(s) = s s s + 4 MATLAB commands are» num = [ 4]; den = [1 4];» impulse(num,den,10) Duration of simulation (10 sec.) ME 304 3/50

33 Unit Step Response As an illustration, let G(s) = s s s + 4 MATLAB commands are» num = [ 4]; den = [1 4];» step(num,den,10) Duration of simulation (10 sec.) ME /50

34 Simulink Run MATLAB (Latest version 6.5 Rev13) Welcome screen of Matlab Select Simulink Simulink Library Browser ME /50

35 Select NEW or OPEN (a previous model file) ME /50

36 An Untitled model is opened and using Simulink Library you can create your model. ME /50

37 Under Sources Select Signal Generator and drag into model ME /50

38 Under Sinks Select Scope and drag into model ME /50

39 Under Signals and Systems Select Mux and drag into model ME /50

40 Select PID Controller Under Simulink Extras Additional Linear and drag into model ME /50

41 Under Discontinuities Select Saturation and drag into model ME /50

42 Under Math Operations Select Sum and drag into model ME 304 4/50

43 Complete Model ME /50

44 Select Simulation Parameters under Simulation Menu ME /50

45 Set Solver Parameters ME /50

46 Set Scope Parameters ME /50

47 Set Format to Array, remove the tick on Limit data points to last, tick Save data to workspace,, and give a variable name. ME /50

48 You may plot the response by using plot command on the command window by using the data saved in the workspace. ME /50

49 Examples from System Responses (PD-control) ME /50

50 END ME /50

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

MATLAB Premier. Asst. Prof. Dr. Melik DÖLEN. Middle East Technical University Department of Mechanical Engineering 10/30/04 ME 304 1 MATLAB Premier Asst. Prof. Dr. Melik DÖLEN Middle East Technical University Department of Mechanical Engineering 0/0/04 ME 04 Outline! Introduction! Basic Features of MATLAB! Prompt Level and Basic Aritmetic

More information

What is MATLAB? What is MATLAB? Programming Environment MATLAB PROGRAMMING. Stands for MATrix LABoratory. A programming environment

What is MATLAB? What is MATLAB? Programming Environment MATLAB PROGRAMMING. Stands for MATrix LABoratory. A programming environment What is MATLAB? MATLAB PROGRAMMING Stands for MATrix LABoratory A software built around vectors and matrices A great tool for numerical computation of mathematical problems, such as Calculus Has powerful

More information

Matlab (Matrix laboratory) is an interactive software system for numerical computations and graphics.

Matlab (Matrix laboratory) is an interactive software system for numerical computations and graphics. Matlab (Matrix laboratory) is an interactive software system for numerical computations and graphics. Starting MATLAB - On a PC, double click the MATLAB icon - On a LINUX/UNIX machine, enter the command:

More information

Introduction to Octave/Matlab. Deployment of Telecommunication Infrastructures

Introduction to Octave/Matlab. Deployment of Telecommunication Infrastructures Introduction to Octave/Matlab Deployment of Telecommunication Infrastructures 1 What is Octave? Software for numerical computations and graphics Particularly designed for matrix computations Solving equations,

More information

2.0 MATLAB Fundamentals

2.0 MATLAB Fundamentals 2.0 MATLAB Fundamentals 2.1 INTRODUCTION MATLAB is a computer program for computing scientific and engineering problems that can be expressed in mathematical form. The name MATLAB stands for MATrix LABoratory,

More information

Inlichtingenblad, matlab- en simulink handleiding en practicumopgaven IWS

Inlichtingenblad, matlab- en simulink handleiding en practicumopgaven IWS Inlichtingenblad, matlab- en simulink handleiding en practicumopgaven IWS 1 6 3 Matlab 3.1 Fundamentals Matlab. The name Matlab stands for matrix laboratory. Main principle. Matlab works with rectangular

More information

Introduction to Matlab. Summer School CEA-EDF-INRIA 2011 of Numerical Analysis

Introduction to Matlab. Summer School CEA-EDF-INRIA 2011 of Numerical Analysis Introduction to Matlab 1 Outline What is Matlab? Matlab desktop & interface Scalar variables Vectors and matrices Exercise 1 Booleans Control structures File organization User defined functions Exercise

More information

Introduction to MATLAB

Introduction to MATLAB CHEE MATLAB Tutorial Introduction to MATLAB Introduction In this tutorial, you will learn how to enter matrices and perform some matrix operations using MATLAB. MATLAB is an interactive program for numerical

More information

MATLAB Lecture 1. Introduction to MATLAB

MATLAB Lecture 1. Introduction to MATLAB MATLAB Lecture 1. Introduction to MATLAB 1.1 The MATLAB environment MATLAB is a software program that allows you to compute interactively with matrices. If you want to know for instance the product of

More information

2. Introduction to Matlab Control System Toolbox

2. Introduction to Matlab Control System Toolbox . Introduction to Matlab Control System Toolbox Consider a single-input, single-output (SISO), continuous-time, linear, time invariant (LTI) system defined by its transfer function: u(t) Y( S) num y(t)

More information

16.06/16.07 Matlab/Simulink Tutorial

16.06/16.07 Matlab/Simulink Tutorial Massachusetts Institute of Technology 16.06/16.07 Matlab/Simulink Tutorial Version 1.0 September 2004 Theresa Robinson Nayden Kambouchev 1 Where to Find More Information There are many webpages which contain

More information

UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER

UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER BENC 2113 DENC ECADD 2532 ECADD LAB SESSION 6/7 LAB

More information

Introduction to MATLAB LAB 1

Introduction to MATLAB LAB 1 Introduction to MATLAB LAB 1 1 Basics of MATLAB MATrix LABoratory A super-powerful graphing calculator Matrix based numeric computation Embedded Functions Also a programming language User defined functions

More information

A Brief Introduction to MATLAB

A Brief Introduction to MATLAB A Brief Introduction to MATLAB MATLAB (Matrix Laboratory) is an interactive software system for numerical computations and graphics. As the name suggests, MATLAB was first designed for matrix computations:

More information

Stokes Modelling Workshop

Stokes Modelling Workshop Stokes Modelling Workshop 14/06/2016 Introduction to Matlab www.maths.nuigalway.ie/modellingworkshop16/files 14/06/2016 Stokes Modelling Workshop Introduction to Matlab 1 / 16 Matlab As part of this crash

More information

Introduction to Matlab. By: Dr. Maher O. EL-Ghossain

Introduction to Matlab. By: Dr. Maher O. EL-Ghossain Introduction to Matlab By: Dr. Maher O. EL-Ghossain Outline: q What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators (Arithmetic, relational, logical ) Display Facilities Flow Control

More information

(Creating Arrays & Matrices) Applied Linear Algebra in Geoscience Using MATLAB

(Creating Arrays & Matrices) Applied Linear Algebra in Geoscience Using MATLAB Applied Linear Algebra in Geoscience Using MATLAB (Creating Arrays & Matrices) Contents Getting Started Creating Arrays Mathematical Operations with Arrays Using Script Files and Managing Data Two-Dimensional

More information

MATLAB Tutorial. 1. The MATLAB Windows. 2. The Command Windows. 3. Simple scalar or number operations

MATLAB Tutorial. 1. The MATLAB Windows. 2. The Command Windows. 3. Simple scalar or number operations MATLAB Tutorial The following tutorial has been compiled from several resources including the online Help menu of MATLAB. It contains a list of commands that will be directly helpful for understanding

More information

MATLAB Tutorial. Mohammad Motamed 1. August 28, generates a 3 3 matrix.

MATLAB Tutorial. Mohammad Motamed 1. August 28, generates a 3 3 matrix. MATLAB Tutorial 1 1 Department of Mathematics and Statistics, The University of New Mexico, Albuquerque, NM 87131 August 28, 2016 Contents: 1. Scalars, Vectors, Matrices... 1 2. Built-in variables, functions,

More information

University of Alberta

University of Alberta A Brief Introduction to MATLAB University of Alberta M.G. Lipsett 2008 MATLAB is an interactive program for numerical computation and data visualization, used extensively by engineers for analysis of systems.

More information

Desktop Command window

Desktop Command window Chapter 1 Matlab Overview EGR1302 Desktop Command window Current Directory window Tb Tabs to toggle between Current Directory & Workspace Windows Command History window 1 Desktop Default appearance Command

More information

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

Lab. Manual. Practical Special Topics (Matlab Programming) (EngE416) Prepared By Dr. Emad Saeid KINGDOM OF SAUDI ARABIA JAZAN UNIVERSTY College of Engineering Electrical Engineering Department المملكة العربية السعودية وزارة التعليم العالي جامعة جازان كلية الھندسة قسم الھندسة الكھربائية Lab. Manual

More information

A GUIDE FOR USING MATLAB IN COMPUTER SCIENCE AND COMPUTER ENGINEERING TABLE OF CONTENTS

A GUIDE FOR USING MATLAB IN COMPUTER SCIENCE AND COMPUTER ENGINEERING TABLE OF CONTENTS A GUIDE FOR USING MATLAB IN COMPUTER SCIENCE AND COMPUTER ENGINEERING MARC THOMAS AND CHRISTOPHER PASCUA TABLE OF CONTENTS 1. Language Usage and Matlab Interface 1 2. Matlab Global Syntax and Semantic

More information

Introduction to MATLAB

Introduction to MATLAB 58:110 Computer-Aided Engineering Spring 2005 Introduction to MATLAB Department of Mechanical and industrial engineering January 2005 Topics Introduction Running MATLAB and MATLAB Environment Getting help

More information

Grace days can not be used for this assignment

Grace days can not be used for this assignment CS513 Spring 19 Prof. Ron Matlab Assignment #0 Prepared by Narfi Stefansson Due January 30, 2019 Grace days can not be used for this assignment The Matlab assignments are not intended to be complete tutorials,

More information

MATLAB and Numerical Analysis

MATLAB and Numerical Analysis School of Mechanical Engineering Pusan National University dongwoonkim@pusan.ac.kr Teaching Assistant 김동운 dongwoonkim@pusan.ac.kr 윤종희 jongheeyun@pusan.ac.kr Lab office: 통합기계관 120호 ( 510-3921) 방사선영상연구실홈페이지

More information

INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX

INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX 1) Objective The objective of this lab is to review how to access Matlab, Simulink, and the Communications Toolbox, and to become familiar

More information

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB MATLAB sessions: Laboratory MAT 75 Laboratory Matrix Computations and Programming in MATLAB In this laboratory session we will learn how to. Create and manipulate matrices and vectors.. Write simple programs

More information

MATH 5520 Basics of MATLAB

MATH 5520 Basics of MATLAB MATH 5520 Basics of MATLAB Dmitriy Leykekhman Spring 2011 Topics Sources. Entering Matrices. Basic Operations with Matrices. Build in Matrices. Build in Scalar and Matrix Functions. if, while, for m-files

More information

MATH 3511 Basics of MATLAB

MATH 3511 Basics of MATLAB MATH 3511 Basics of MATLAB Dmitriy Leykekhman Spring 2012 Topics Sources. Entering Matrices. Basic Operations with Matrices. Build in Matrices. Build in Scalar and Matrix Functions. if, while, for m-files

More information

Some elements for Matlab programming

Some elements for Matlab programming Some elements for Matlab programming Nathalie Thomas 2018 2019 Matlab, which stands for the abbreviation of MATrix LABoratory, is one of the most popular language for scientic computation. The classical

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab Andreas C. Kapourani (Credit: Steve Renals & Iain Murray) 9 January 08 Introduction MATLAB is a programming language that grew out of the need to process matrices. It is used extensively

More information

Introduction to MATLAB

Introduction to MATLAB ELG 3125 - Lab 1 Introduction to MATLAB TA: Chao Wang (cwang103@site.uottawa.ca) 2008 Fall ELG 3125 Signal and System Analysis P. 1 Do You Speak MATLAB? MATLAB - The Language of Technical Computing ELG

More information

Introduction to MatLab. Introduction to MatLab K. Craig 1

Introduction to MatLab. Introduction to MatLab K. Craig 1 Introduction to MatLab Introduction to MatLab K. Craig 1 MatLab Introduction MatLab and the MatLab Environment Numerical Calculations Basic Plotting and Graphics Matrix Computations and Solving Equations

More information

Getting started with MATLAB

Getting started with MATLAB Sapienza University of Rome Department of economics and law Advanced Monetary Theory and Policy EPOS 2013/14 Getting started with MATLAB Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Outline

More information

A Guide to Using Some Basic MATLAB Functions

A Guide to Using Some Basic MATLAB Functions A Guide to Using Some Basic MATLAB Functions UNC Charlotte Robert W. Cox This document provides a brief overview of some of the essential MATLAB functionality. More thorough descriptions are available

More information

STAT/MATH 395 A - PROBABILITY II UW Winter Quarter Matlab Tutorial

STAT/MATH 395 A - PROBABILITY II UW Winter Quarter Matlab Tutorial STAT/MATH 395 A - PROBABILITY II UW Winter Quarter 2016 Néhémy Lim Matlab Tutorial 1 Introduction Matlab (standing for matrix laboratory) is a high-level programming language and interactive environment

More information

Eric W. Hansen. The basic data type is a matrix This is the basic paradigm for computation with MATLAB, and the key to its power. Here s an example:

Eric W. Hansen. The basic data type is a matrix This is the basic paradigm for computation with MATLAB, and the key to its power. Here s an example: Using MATLAB for Stochastic Simulation. Eric W. Hansen. Matlab Basics Introduction MATLAB (MATrix LABoratory) is a software package designed for efficient, reliable numerical computing. Using MATLAB greatly

More information

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

MATLAB BASICS. < Any system: Enter quit at Matlab prompt < PC/Windows: Close command window < To interrupt execution: Enter Ctrl-c. MATLAB BASICS Starting Matlab < PC: Desktop icon or Start menu item < UNIX: Enter matlab at operating system prompt < Others: Might need to execute from a menu somewhere Entering Matlab commands < Matlab

More information

Chapter 1 Introduction to MATLAB

Chapter 1 Introduction to MATLAB Chapter 1 Introduction to MATLAB 1.1 What is MATLAB? MATLAB = MATrix LABoratory, the language of technical computing, modeling and simulation, data analysis and processing, visualization and graphics,

More information

Introduction to. The Help System. Variable and Memory Management. Matrices Generation. Interactive Calculations. Vectors and Matrices

Introduction to. The Help System. Variable and Memory Management. Matrices Generation. Interactive Calculations. Vectors and Matrices Introduction to Interactive Calculations Matlab is interactive, no need to declare variables >> 2+3*4/2 >> V = 50 >> V + 2 >> V Ans = 52 >> a=5e-3; b=1; a+b Most elementary functions and constants are

More information

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

MATLAB Basics. Configure a MATLAB Package 6/7/2017. Stanley Liang, PhD York University. Get a MATLAB Student License on Matworks MATLAB Basics Stanley Liang, PhD York University Configure a MATLAB Package Get a MATLAB Student License on Matworks Visit MathWorks at https://www.mathworks.com/ It is recommended signing up with a student

More information

Introduction to the MATLAB SIMULINK Program

Introduction to the MATLAB SIMULINK Program Introduction to the MATLAB SIMULINK Program Adapted from similar document by Dept. of Chemical Engineering, UC - Santa Barbara MATLAB, which stands for MATrix LABoratory, is a technical computing environment

More information

Constraint-based Metabolic Reconstructions & Analysis H. Scott Hinton. Matlab Tutorial. Lesson: Matlab Tutorial

Constraint-based Metabolic Reconstructions & Analysis H. Scott Hinton. Matlab Tutorial. Lesson: Matlab Tutorial 1 Matlab Tutorial 2 Lecture Learning Objectives Each student should be able to: Describe the Matlab desktop Explain the basic use of Matlab variables Explain the basic use of Matlab scripts Explain the

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab 1 Outline: What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators (Arithmetic, relational, logical ) Display Facilities Flow Control Using of M-File Writing User

More information

Matlab Tutorial, CDS

Matlab Tutorial, CDS 29 September 2006 Arrays Built-in variables Outline Operations Linear algebra Polynomials Scripts and data management Help: command window Elisa (see Franco next slide), Matlab Tutorial, i.e. >> CDS110-101

More information

A very brief Matlab introduction

A very brief Matlab introduction A very brief Matlab introduction Siniša Krajnović January 24, 2006 This is a very brief introduction to Matlab and its purpose is only to introduce students of the CFD course into Matlab. After reading

More information

CDA5530: Performance Models of Computers and Networks. Chapter 8: Using Matlab for Performance Analysis and Simulation

CDA5530: Performance Models of Computers and Networks. Chapter 8: Using Matlab for Performance Analysis and Simulation CDA5530: Performance Models of Computers and Networks Chapter 8: Using Matlab for Performance Analysis and Simulation Objective Learn a useful tool for mathematical analysis and simulation Interpreted

More information

MATLAB Tutorial. Digital Signal Processing. Course Details. Topics. MATLAB Environment. Introduction. Digital Signal Processing (DSP)

MATLAB Tutorial. Digital Signal Processing. Course Details. Topics. MATLAB Environment. Introduction. Digital Signal Processing (DSP) Digital Signal Processing Prof. Nizamettin AYDIN naydin@yildiz.edu.tr naydin@ieee.org http://www.yildiz.edu.tr/~naydin Course Details Course Code : 0113620 Course Name: Digital Signal Processing (Sayısal

More information

A Quick Tutorial on MATLAB. Zeeshan Ali

A Quick Tutorial on MATLAB. Zeeshan Ali A Quick Tutorial on MATLAB Zeeshan Ali MATLAB MATLAB is a software package for doing numerical computation. It was originally designed for solving linear algebra type problems using matrices. It's name

More information

This is a basic tutorial for the MATLAB program which is a high-performance language for technical computing for platforms:

This is a basic tutorial for the MATLAB program which is a high-performance language for technical computing for platforms: Appendix A Basic MATLAB Tutorial Extracted from: http://www1.gantep.edu.tr/ bingul/ep375 http://www.mathworks.com/products/matlab A.1 Introduction This is a basic tutorial for the MATLAB program which

More information

MATLAB Tutorial EE351M DSP. Created: Thursday Jan 25, 2007 Rayyan Jaber. Modified by: Kitaek Bae. Outline

MATLAB Tutorial EE351M DSP. Created: Thursday Jan 25, 2007 Rayyan Jaber. Modified by: Kitaek Bae. Outline MATLAB Tutorial EE351M DSP Created: Thursday Jan 25, 2007 Rayyan Jaber Modified by: Kitaek Bae Outline Part I: Introduction and Overview Part II: Matrix manipulations and common functions Part III: Plots

More information

Chapter 1 MATLAB Preliminaries

Chapter 1 MATLAB Preliminaries Chapter 1 MATLAB Preliminaries 1.1 INTRODUCTION MATLAB (Matrix Laboratory) is a high-level technical computing environment developed by The Mathworks, Inc. for mathematical, scientific, and engineering

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab By:Mohammad Sadeghi *Dr. Sajid Gul Khawaja Slides has been used partially to prepare this presentation Outline: What is Matlab? Matlab Screen Basic functions Variables, matrix, indexing

More information

Lecturer: Keyvan Dehmamy

Lecturer: Keyvan Dehmamy MATLAB Tutorial Lecturer: Keyvan Dehmamy 1 Topics Introduction Running MATLAB and MATLAB Environment Getting help Variables Vectors, Matrices, and linear Algebra Mathematical Functions and Applications

More information

MATLAB BEGINNER S GUIDE

MATLAB BEGINNER S GUIDE MATLAB BEGINNER S GUIDE About MATLAB MATLAB is an interactive software which has been used recently in various areas of engineering and scientific applications. It is not a computer language in the normal

More information

A General Introduction to Matlab

A General Introduction to Matlab Master Degree Course in ELECTRONICS ENGINEERING http://www.dii.unimore.it/~lbiagiotti/systemscontroltheory.html A General Introduction to Matlab e-mail: luigi.biagiotti@unimore.it http://www.dii.unimore.it/~lbiagiotti

More information

CDA6530: Performance Models of Computers and Networks. Chapter 4: Using Matlab for Performance Analysis and Simulation

CDA6530: Performance Models of Computers and Networks. Chapter 4: Using Matlab for Performance Analysis and Simulation CDA6530: Performance Models of Computers and Networks Chapter 4: Using Matlab for Performance Analysis and Simulation Objective Learn a useful tool for mathematical analysis and simulation Interpreted

More information

Laboratory 1 Octave Tutorial

Laboratory 1 Octave Tutorial Signals, Spectra and Signal Processing Laboratory 1 Octave Tutorial 1.1 Introduction The purpose of this lab 1 is to become familiar with the GNU Octave 2 software environment. 1.2 Octave Review All laboratory

More information

CDA6530: Performance Models of Computers and Networks. Chapter 4: Using Matlab for Performance Analysis and Simulation

CDA6530: Performance Models of Computers and Networks. Chapter 4: Using Matlab for Performance Analysis and Simulation CDA6530: Performance Models of Computers and Networks Chapter 4: Using Matlab for Performance Analysis and Simulation Objective Learn a useful tool for mathematical analysis and simulation Interpreted

More information

Matlab and Octave: Quick Introduction and Examples 1 Basics

Matlab and Octave: Quick Introduction and Examples 1 Basics Matlab and Octave: Quick Introduction and Examples 1 Basics 1.1 Syntax and m-files There is a shell where commands can be written in. All commands must either be built-in commands, functions, names of

More information

Experiment 1: Introduction to MATLAB I. Introduction. 1.1 Objectives and Expectations: 1.2 What is MATLAB?

Experiment 1: Introduction to MATLAB I. Introduction. 1.1 Objectives and Expectations: 1.2 What is MATLAB? Experiment 1: Introduction to MATLAB I Introduction MATLAB, which stands for Matrix Laboratory, is a very powerful program for performing numerical and symbolic calculations, and is widely used in science

More information

MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB

MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB MATLAB is a computer software commonly used in both education and industry to solve a wide range of problems. This Laboratory provides a brief

More information

CSE/Math 456 and CSE/Math 550 Matlab Tutorial and Demo

CSE/Math 456 and CSE/Math 550 Matlab Tutorial and Demo CSE/Math 456 and CSE/Math 550 Matlab Tutorial and Demo MATLAB is very powerful and varied software package for scientific computing. It is based upon matrices and m files. It is invoked by typing % matlab

More information

MATLAB QUICK START TUTORIAL

MATLAB QUICK START TUTORIAL MATLAB QUICK START TUTORIAL This tutorial is a brief introduction to MATLAB which is considered one of the most powerful languages of technical computing. In the following sections, the basic knowledge

More information

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB MATLAB sessions: Laboratory MAT 75 Laboratory Matrix Computations and Programming in MATLAB In this laboratory session we will learn how to. Create and manipulate matrices and vectors.. Write simple programs

More information

MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB

MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB In this laboratory session we will learn how to 1. Create matrices and vectors. 2. Manipulate matrices and create matrices of special types

More information

Matlab Tutorial. Get familiar with MATLAB by using tutorials and demos found in MATLAB. You can click Start MATLAB Demos to start the help screen.

Matlab Tutorial. Get familiar with MATLAB by using tutorials and demos found in MATLAB. You can click Start MATLAB Demos to start the help screen. University of Illinois at Urbana-Champaign Department of Electrical and Computer Engineering ECE 298JA Fall 2015 Matlab Tutorial 1 Overview The goal of this tutorial is to help you get familiar with MATLAB

More information

Computational Foundations of Cognitive Science. Inverse. Inverse. Inverse Determinant

Computational Foundations of Cognitive Science. Inverse. Inverse. Inverse Determinant Computational Foundations of Cognitive Science Lecture 14: s and in Matlab; Plotting and Graphics Frank Keller School of Informatics University of Edinburgh keller@inf.ed.ac.uk February 23, 21 1 2 3 Reading:

More information

Matlab Introduction. Scalar Variables and Arithmetic Operators

Matlab Introduction. Scalar Variables and Arithmetic Operators Matlab Introduction Matlab is both a powerful computational environment and a programming language that easily handles matrix and complex arithmetic. It is a large software package that has many advanced

More information

Teaching Manual Math 2131

Teaching Manual Math 2131 Math 2131 Linear Algebra Labs with MATLAB Math 2131 Linear algebra with Matlab Teaching Manual Math 2131 Contents Week 1 3 1 MATLAB Course Introduction 5 1.1 The MATLAB user interface...........................

More information

Variable Definition and Statement Suppression You can create your own variables, and assign them values using = >> a = a = 3.

Variable Definition and Statement Suppression You can create your own variables, and assign them values using = >> a = a = 3. MATLAB Introduction Accessing Matlab... Matlab Interface... The Basics... 2 Variable Definition and Statement Suppression... 2 Keyboard Shortcuts... More Common Functions... 4 Vectors and Matrices... 4

More information

FreeMat Tutorial. 3x + 4y 2z = 5 2x 5y + z = 8 x x + 3y = -1 xx

FreeMat Tutorial. 3x + 4y 2z = 5 2x 5y + z = 8 x x + 3y = -1 xx 1 of 9 FreeMat Tutorial FreeMat is a general purpose matrix calculator. It allows you to enter matrices and then perform operations on them in the same way you would write the operations on paper. This

More information

AMATH 352: MATLAB Tutorial written by Peter Blossey Department of Applied Mathematics University of Washington Seattle, WA

AMATH 352: MATLAB Tutorial written by Peter Blossey Department of Applied Mathematics University of Washington Seattle, WA AMATH 352: MATLAB Tutorial written by Peter Blossey Department of Applied Mathematics University of Washington Seattle, WA MATLAB (short for MATrix LABoratory) is a very useful piece of software for numerical

More information

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

Here is a quick introduction to Matlab and a couple of its symbolic and control functions. Some Matlab 1 Here is a quick introduction to Matlab and a couple of its symbolic and control functions. Matlab is an interpreted language. When you enter a command in the Command window, the line is executed

More information

AN INTRODUCTION TO MATLAB

AN INTRODUCTION TO MATLAB AN INTRODUCTION TO MATLAB 1 Introduction MATLAB is a powerful mathematical tool used for a number of engineering applications such as communication engineering, digital signal processing, control engineering,

More information

MatLab Just a beginning

MatLab Just a beginning MatLab Just a beginning P.Kanungo Dept. of E & TC, C.V. Raman College of Engineering, Bhubaneswar Introduction MATLAB is a high-performance language for technical computing. MATLAB is an acronym for MATrix

More information

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB MAT 75 Laboratory Matrix Computations and Programming in MATLAB In this laboratory session we will learn how to. Create and manipulate matrices and vectors.. Write simple programs in MATLAB NOTE: For your

More information

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB Introduction MATLAB is an interactive package for numerical analysis, matrix computation, control system design, and linear system analysis and design available on most CAEN platforms

More information

Digital Image Analysis and Processing CPE

Digital Image Analysis and Processing CPE Digital Image Analysis and Processing CPE 0907544 Matlab Tutorial Dr. Iyad Jafar Outline Matlab Environment Matlab as Calculator Common Mathematical Functions Defining Vectors and Arrays Addressing Vectors

More information

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

BRUSH UP ON MATLAB UNIVERSITY OF PAVIA. Industrial Control FACULTY OF ENGINEERING. Prof. Lalo Magni UNIVERSITY OF PAVIA FACULTY OF ENGINEERING Industrial Control Prof. Lalo Magni BRUSH UP ON MATLAB Chiara Toffanin, Assistant Professor Gian Paolo Incremona, Ph.D. MATLAB: What is it? MATLAB (from MATrix

More information

Fall 2014 MAT 375 Numerical Methods. Introduction to Programming using MATLAB

Fall 2014 MAT 375 Numerical Methods. Introduction to Programming using MATLAB Fall 2014 MAT 375 Numerical Methods Introduction to Programming using MATLAB Some useful links 1 The MOST useful link: www.google.com 2 MathWorks Webcite: www.mathworks.com/help/matlab/ 3 Wikibooks on

More information

PC-MATLAB PRIMER. This is intended as a guided tour through PCMATLAB. Type as you go and watch what happens.

PC-MATLAB PRIMER. This is intended as a guided tour through PCMATLAB. Type as you go and watch what happens. PC-MATLAB PRIMER This is intended as a guided tour through PCMATLAB. Type as you go and watch what happens. >> 2*3 ans = 6 PCMATLAB uses several lines for the answer, but I ve edited this to save space.

More information

Signals and Systems INTRODUCTION TO MATLAB Fall Thomas F. Weiss

Signals and Systems INTRODUCTION TO MATLAB Fall Thomas F. Weiss MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Electrical Engineering and Computer Science Signals and Systems 6.3 INTRODUCTION TO MATLAB Fall 1999 Thomas F. Weiss Last modification September 9, 1999

More information

Introduction to MATLAB 7 for Engineers

Introduction to MATLAB 7 for Engineers PowerPoint to accompany Introduction to MATLAB 7 for Engineers William J. Palm III Chapter 2 Numeric, Cell, and Structure Arrays Copyright 2005. The McGraw-Hill Companies, Inc. Permission required for

More information

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB 1 Introduction to MATLAB A Tutorial for the Course Computational Intelligence http://www.igi.tugraz.at/lehre/ci Stefan Häusler Institute for Theoretical Computer Science Inffeldgasse

More information

Introduction to Engineering gii

Introduction to Engineering gii 25.108 Introduction to Engineering gii Dr. Jay Weitzen Lecture Notes I: Introduction to Matlab from Gilat Book MATLAB - Lecture # 1 Starting with MATLAB / Chapter 1 Topics Covered: 1. Introduction. 2.

More information

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB Basics MATLAB is a high-level interpreted language, and uses a read-evaluate-print loop: it reads your command, evaluates it, then prints the answer. This means it works a lot like

More information

MATLAB GUIDE UMD PHYS401 SPRING 2012

MATLAB GUIDE UMD PHYS401 SPRING 2012 MATLAB GUIDE UMD PHYS40 SPRING 202 We will be using Matlab (or, equivalently, the free clone GNU/Octave) this semester to perform calculations involving matrices and vectors. This guide gives a brief introduction

More information

Introduction to MATLAB

Introduction to MATLAB Quick Start Tutorial Introduction to MATLAB Hans-Petter Halvorsen, M.Sc. What is MATLAB? MATLAB is a tool for technical computing, computation and visualization in an integrated environment. MATLAB is

More information

A Tour of Matlab for Math 496, Section 6

A Tour of Matlab for Math 496, Section 6 A Tour of Matlab for Math 496, Section 6 Thomas Shores Department of Mathematics University of Nebraska Spring 2006 What is Matlab? Matlab is 1. An interactive system for numerical computation. 2. A programmable

More information

Matlab Tutorial. The value assigned to a variable can be checked by simply typing in the variable name:

Matlab Tutorial. The value assigned to a variable can be checked by simply typing in the variable name: 1 Matlab Tutorial 1- What is Matlab? Matlab is a powerful tool for almost any kind of mathematical application. It enables one to develop programs with a high degree of functionality. The user can write

More information

Matlab Tutorial Francesco Franco

Matlab Tutorial Francesco Franco Matlab Tutorial Francesco Franco Matlab is a software package that makes it easier for you to enter matrices and vectors, and manipulate them. The interface follows a language that is designed to look

More information

General MATLAB Information 1

General MATLAB Information 1 Introduction to MATLAB General MATLAB Information 1 Once you initiate the MATLAB software, you will see the MATLAB logo appear and then the MATLAB prompt >>. The prompt >> indicates that MATLAB is awaiting

More information

Matlab course at. P. Ciuciu 1,2. 1: CEA/NeuroSpin/LNAO 2: IFR49

Matlab course at. P. Ciuciu 1,2. 1: CEA/NeuroSpin/LNAO 2: IFR49 Matlab course at NeuroSpin P. Ciuciu 1,2 philippe.ciuciu@cea.fr www.lnao.fr 1: CEA/NeuroSpin/LNAO 2: IFR49 Feb 26, 2009 Outline 2/9 Lesson0: Getting started: environment,.m and.mat files Lesson I: Scalar,

More information

An Introduction to Numerical Methods

An Introduction to Numerical Methods An Introduction to Numerical Methods Using MATLAB Khyruddin Akbar Ansari, Ph.D., P.E. Bonni Dichone, Ph.D. SDC P U B L I C AT I O N S Better Textbooks. Lower Prices. www.sdcpublications.com Powered by

More information

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB MATLAB stands for MATrix LABoratory. Originally written by Cleve Moler for college linear algebra courses, MATLAB has evolved into the premier software for linear algebra computations

More information

Introduction to MATLAB. Simon O Keefe Non-Standard Computation Group

Introduction to MATLAB. Simon O Keefe Non-Standard Computation Group Introduction to MATLAB Simon O Keefe Non-Standard Computation Group sok@cs.york.ac.uk Content n An introduction to MATLAB n The MATLAB interfaces n Variables, vectors and matrices n Using operators n Using

More information

Introduction to MATLAB Practical 1

Introduction to MATLAB Practical 1 Introduction to MATLAB Practical 1 Daniel Carrera November 2016 1 Introduction I believe that the best way to learn Matlab is hands on, and I tried to design this practical that way. I assume no prior

More information

Lecture 2: Variables, Vectors and Matrices in MATLAB

Lecture 2: Variables, Vectors and Matrices in MATLAB Lecture 2: Variables, Vectors and Matrices in MATLAB Dr. Mohammed Hawa Electrical Engineering Department University of Jordan EE201: Computer Applications. See Textbook Chapter 1 and Chapter 2. Variables

More information