MATLAB Tutorial The Basics

Size: px
Start display at page:

Download "MATLAB Tutorial The Basics"

Transcription

1 MATLAB Tutorial The Basics Chienmin Chuang School of Mathematics, University of Birmingham May 24, 2011

2 WHAT IS MATLAB? MATLAB, coined from MATrix LABoratory, is a mathematical computing software developed by MathWorks. Simply speaking, it can be thought as a calculator which is powerful in matrix operations. To a further extent, it is a powerful programming language equipped with various built-in functions and (optional) tool boxes and can be used to build a customized program.

3 HOW TO START MATLAB? Simply double click the MATLAB icon on your desktop or execute the program from the start menu. You will see the Current Directory on the top row of the interface where you create, save and connect all your programs and files. In addition, there are three main windows: Workspace: All the variables currently used are displayed here. Command: Used for executing all commands, built-in functions and your own programs. History: Show what you have done on MATLAB.

4 HOW TO START MATLAB? Your best friend when using MatLab help function. Simply type Help, you can get instruction of how to use MATLAB. To know how to use a certain built-in function, simply type help <function-name>. Another choice: Help>Using the Command Window.

5 NUMERICAL VARIABLE Type any number in the command window and then press Enter. MATLAB always echoes back with ans=the typed number. MATLAB generates the ans variable automatically when a user specifies no output argument. A user can define a numerical variable using the syntax: variable-name = numerical value. An semicolon (;) can be put in the end for no echo.

6 NUMERICAL VARIABLE Some preset constants are i and j both refer to 1. pi is the ratio of circle s circumference to its diameter. Nan refers to Not a Number and has the form 0/0. Inf refers to Infinity and has the form 1/0. Technical points: 1. Preset names can be reloaded with new values or data. 2. Inf-Inf and Inf/Inf both produce NaN. 3. The exponential base is not preset as e. To define the number, we can use e=exp(1).

7 DISPLAY FORMATS Numerical values or variables can be displayed in different formats. Below are widely used types: format short/long displays values with 4/14-15 digits after the decimal point. format short/long eng displays values in the engineering format with 4/16 digits after the point. format rat displays values in terms of an rational number which may be exact or approximate to the original one. Short is he default format type. Simply type help format for more details.

8 ARITHMETIC OPERATIONS Five basic operations: + (add), -(subtract), * (multiply), (divide) and ˆ(exponentiate or raise to a power). Tips: 1. Priority: ˆ, / +,. 2. Use space and bracket () for clear expression. 3. A comma, is used to separate two expressions. 4. If a semicolon ; ends an equation, the result will not be shown on the screen. It is also used to end a line of command and separate it from the next one. 5. A variable can be defined by simply assigning a value to the variable name. To clear a variable x from memory, simply type clear x. clear all clears all variables. Note that MATLAB are case-sensitive to variable names. 6. To check what variables are currently used, type whos.

9 ARITHMETIC OPERATIONS The command clc is used to to clear command window.

10 ELEMENTARY FUNCTIONS There are a variety of elementary mathematical functions built in MATLAB. Type help elfun in the command window for all details. We introduce a few here. For any variable (or value) x: log(x): Natural logarithm of x. exp(x): Exponential of x or e = to power x. sin(x), cos(x), tan(x), cot(x), sec(x), csc(x): Trigonometric functions of x. abs(x): Modulus or absolute value of x. sqrt(x): Square root of X. conj(x): Complex conjugate of x. imag(x): Complex imaginary part of x. real(x): Complex real part of x.

11 DEFINE A VECTOR Below are common ways to define a horizontal row vector. a:incerment:b Defines a row vector with starting entry a and the last entry (less than or) equal to b in the step of increment. In particular, a:b is the shorthand of a:1:b. linspace(a,b,n) Defines a row vector with starting entry a and the last entry equal to b with n equidistant entries in total.

12 DEFINE A MATRIX When defining a matrix or vector,, separate entries in the same row which can also be replaced by space. ; separate different rows. [ ] is used to cover all its entry values. Besides, [ ] can also combine two matrices to a bigger one. We can also define an empty matrix by C=[]. For example,

13 DEFINE A MATRIX Several functions used to define specific matrices: zeros(m,n) defines an m n zero matrix. ones(m,n) defines an m n matrix with entries equal to one. eye(m,n) defines an m n matrix with main-diagonal entries equal to one and others equal to zero. In particular, eye(m,m) can be shortened to eye(m) and defines a m m identity matrix. rand(m,n) generates an m n random matrix with entries drawn from a uniform distribution over [0, 1]. randn(m,n) generates an m n random matrix with entries drawn from a normal distribution with zero mean and unit variance.

14 DEFINE A MATRIX Provided values x 0, x 1,..., x n, a Vander matrix is a matrix of the form below. x n 0 x 2 0 x 0 1 x n 1 x 2 1 x 1 1 x n 2 x 2 2 x x n n x 2 n x n 1 Such a matrix is useful when doing nth-order interpolation and can be generated by MatLab using vander([x 0 ; x 1 ;... ; x n ]).

15 MATRIX MANIPULATION If two matrices A and B are compatible in dimensions, we can use the following matrix operations. Basics: A + B A B A B Inverse for a square matrix C: Power m: C ˆ m In particular, C ˆ ( 1) = inv(c). Transpose: A inv(c) Entry-by-entry operation:../. ˆ For two compatible matrices A and B: A*inv(B)=A/B inv(b)*a=b A To solve a system of equations Ax=b where A is a square matrix and b is a vector, we can use x=inv(a)*b or x=a b. In general, is faster than using inv.

16 MATRIX MANIPULATION Define A=[1 2; 3 4; 5 6], B=[7 8 9; ] and then compute the examples below:

17 INDEXING ENTRIES Suppose M is a n n matrix, then: M(i,j) is the (i,j) entry of M for any i,j<=n. M(i,:) is the ith. row of M for any i<=n. M(:,j) is the jth. column of M for any j<=n. M([r 1 r 2...r m ], [c 1 c 2...c w ]) is a matrix with the (i,j) entry equal to M(r i, c j ); Try the examples:

18 INDEXING ENTRIES For every subscript (i,j), there is a unique single index s corresponding to it. Note that for a row or column vector, we can simply use such a single index to specify an entry.

19 INDEXING ENTRIES To convert between these two indexing methods, we can use sub2ind(sz,i,j): returns a single index using the subscripts (i,j) for a matrix of size sz. ind2sub(sz,s): returns the subscripts (i,j) using a single index s for a matrix of size sz. A matrix M can be easily vectorized in the single order by reloading M=M(:).

20 SET OPERATIONS OF TWO VECTORS Think of two vectors V1 and V2 as two sets. We can do set operations as below. union(v1,v2) generates their union in terms of a row vector. intersect(v1,v2) generates their intersection in terms of a row vector. setdiff(v1,v2) generates their difference in terms of a row vector.

21 FUNCTIONS ASSOCIATED WITH MATRIX Suppose M is a matrix. size(m) returns the size of M. length(m) amounts to max(size(m)). numel(m) returns the number of entries in M. sign(m) returns the signs of all entries in M. Most elementary functions can be applied to a Matrix in terms of entries.

22 FUNCTIONS ASSOCIATED WITH MATRIX Suppose M is a matrix. We can permute its entries in the following ways. sort(m) sort entries in ascending column by column. This is equivalent using sort(m,1). To sort M row by row using sort(m,2). To sort M in descending order, put descend as the last argument. fliplr(m) flips columns of M in the left-right direction. flipud(m) flips columns of M in the up-down direction.

23 FUNCTIONS ASSOCIATED WITH MATRIX diag is a multipurpose function. If v is a n 1 vector, diag(v) defines a diagonal matrix with the main-diagonal entries equal to those of vector v. Moreover, diag(v,k) defines a (n + k ) (n + k ) matrix with the kth-diagonal entries equal to those of vector v. If M is a n m matrix, diag(m,k) returns the kth diagonal of M in terms of a column vector. In particular, diag(m) defines the column vector equal to the main diagonal of M.

24 FUNCTIONS ASSOCIATED WITH MATRIX spdiags(ds,d,m,n) returns an m-by-n sparse matrix by taking the columns of matrix Ds and placing them along the diagonals specified by d. (Beware the entries assigned to non-main-diagonals!) This is particularly convenient for defining tri-diagonal and banded matrices. For more details, refer to ite help file. Note that MATLAB only shows the nonzeros of a sparse matrix. full(m) converts a sparse matrix M to a full one. In contrast, sparse(m) turns the matrix M into a sparse one when existing numerous zero entries. Example:

25 STRING VARIABLE String is a combination of characters, including space. Each entry of a string is a character. Both can be defined using single quote. (Not double quote!) Similar to a matrix variable, length(), numel() and size() can apply to a string variable. A numerical variable can be transformed to a string using num2str(). str2num() can do the reverse. However, if the input string does not represent a valid number or matrix, str2num() returns the empty matrix in x

26 FUNCTIONS ASSOCIATED WITH STRING Strings can be combined by using square brackets []. disp(a) displays the content of variables where a can be a number or a string. whos shows information of all variables while whos( a ) shows information of the variable a. This command can be shortened to who with less information provided. strcmp(s1,s2) compares two string variables s1 and s2, returns 1 if they are identical and 0 otherwise. strncmp(s1,s2,n) compares the first n characters of two string variables s1 and s2 and returns 1 or 0. findstr(s1,s2) searches any occurrences of the shorter string, which returns the starting index of each occurrence if any and empty array [] otherwise. strrep(s,s1,s2) searches the shorter string s1 in a longer string s and replaces s1 by another string s2.

27 FUNCTIONS ASSOCIATED WITH STRING

28 RELATIONAL OPERATORS The relational operators are <, >, <=, >=, ==, and =, which return logical value 1 (true) if the specified relation holds and 0 (false) otherwise. The operators are performed and return values on the elemental basis. Note that = (assign or define) is different from == (equal to). true and false are preset logical variables with values equal to 1 and 0 respectively.

29 REDUCE MULTIPLE RELATIONS TO ONE Suppose N is a numerical matrix and M is a numerical or logical Matrix. or(expr1, expr2) and expr1 expr2 returns 1 if at least one of expr1 and expr2 is equal to logical 1; otherwise, it returns logical 0. and(expr1, expr2) and expr1 & expr2 returns 1 if both expr1 and expr2 are equal to logical 1; otherwise, it returns logical 0. logical(n) transforms N to a logical matrices with 0 corresponding to zero entry of N and 1 to nonzeros. any(m) returns logical value 1 for the column(s) with at least one nonzero entry and logical value 0 otherwise. all(m) returns logical value 1 for the column(s) with all nonzero entries and logical value 0 otherwise.

30 REDUCE MULTIPLE RELATIONS TO ONE

31 CONDITIONER IF if condition The syntax if condition, operations; end or operations; end states: the operations will be performed only if the condition is true. if condition1 operation1; elseif condition2 A more general form is operation2; else operation3; end which states: if the condition1 is true, the operation1 will be performed; else if condition2 is true, the operation2 will be performed; otherwise, the operation3 will be performed. Note that elseif and else can be omitted if not required. Besides, elseif can be used more than once while else can be used at most once.

32 CONDITIONER IF

33 CONDITIONER IF Tips: In general, a nonzero value can be interpreted as a true logical value when used as a condition. transforms the values of true and false to each other. Example:

34 CONDITIONER SWITCH switch scenario-variable case scenario1 operation1;. case scenarion operationn; otherwise operation-for-others; end The syntax states: operationk will be executed if the scenario-variable is equal to the scenariok and operation-for-others will be executed if no matched scenario is available. Note that only one possibility may happen and only its corresponding operation will be performed in the syntax. Note that, we can use curly brackets {} to combines several scenarios as one.

35 CONDITIONER SWITCH

36 LOOP FOR for IndexVariable = a:increment:b operations; end The syntax states the operations will be performed iteratively. The iteration starts from IndexVariable equal to a, go to the next iteration by adding Increment to IndexVariable and stops until the IndexVariable equal to (or more than) b. If the Increment is equal to 1, then the :Increment can be omitted. Note that in the syntax, the value of IndexVariable is assigned as a single scalar, which is different from IndexVariable=a:Increment:b used out of the syntax.

37 LOOP FOR

38 LOOP WHILE while condition operations; end The syntax states: the operations will be repeatedly carried out until the condition does not hold. Note that if the procedure falls into infinite, use Ctrl+C to break the endless iteration. Example:

39 AUXILIARIES FOR LOOPS Commands below can facilitate the usage of for-loop and while-loop which generally follow some specific conditions. break stops the current iteration of a loop and passes control to the outer scope of the loop. continue stops the current iteration of a loop and passes control to the next iteration of the same loop. return hands over the control to its invoking function or the keyboard. Note both break and continue skip the remaining operations of the current iteration after they are active.

40 AUXILIARIES FOR LOOPS

41 2-D PLOT plot(data1, data2) creates a line graph with data1 on x-axis and data 2 on y-axis. Note that the input data are discrete, but plot( ) draws a line graph by connecting all data points. To show all points without connection, we can use plot(data1, data2,. ). To specify more prpperties such as the line width, point shape, color..., etc, use the help file. Similarly, scatter(data1, data2) can draw a scatter plot. bar(data) generates a bar chart for the vector data.

42 2-D PLOT

43 3-D PLOT The three-dimensional versions of previous plotting functions are plot3(data1, data2, data3), bar3(data) and scatter3(data1, data2, data3). Besides, mesh(x,y,z) draws a wireframe mesh using Z for the color data and height. X and Y are vectors or matrices defining the x and y components of a surface. Another choice is to use surf(x,y,z) to create a shaded surface. When plotting in three dimension, [X,Y] = meshgrid(x,y) is useful, which transforms the domain specified by vectors x and y into arrays X and Y

44 3-D PLOT

45 BASIC CONTROL OF GRAPHS grid on and grid off adds and removes the grid of the graph respectively. title( PlotTitle ) set the plot title as Plottitle. xlabel( xname ), ylabel( yname ) and zlabel( zname ) set the names of x,y and z coordinates as xname, yname and zname individually. legend( string1, string2,...) creates a legend using the specified strings to describe each set of data. hold on retains following pictures in the current graph while hold off stops such combining graphs.

46 BASIC CONTROL OF GRAPHS

To start using Matlab, you only need be concerned with the command window for now.

To start using Matlab, you only need be concerned with the command window for now. Getting Started Current folder window Atop the current folder window, you can see the address field which tells you where you are currently located. In programming, think of it as your current directory,

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. Computational Probability and Statistics CIS 2033 Section 003

Introduction to MATLAB. Computational Probability and Statistics CIS 2033 Section 003 Introduction to MATLAB Computational Probability and Statistics CIS 2033 Section 003 About MATLAB MATLAB (MATrix LABoratory) is a high level language made for: Numerical Computation (Technical computing)

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

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

MATLAB Basics EE107: COMMUNICATION SYSTEMS HUSSAIN ELKOTBY

MATLAB Basics EE107: COMMUNICATION SYSTEMS HUSSAIN ELKOTBY MATLAB Basics EE107: COMMUNICATION SYSTEMS HUSSAIN ELKOTBY What is MATLAB? MATLAB (MATrix LABoratory) developed by The Mathworks, Inc. (http://www.mathworks.com) Key Features: High-level language for numerical

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

Chapter 2. MATLAB Fundamentals

Chapter 2. MATLAB Fundamentals Chapter 2. MATLAB Fundamentals Choi Hae Jin Chapter Objectives q Learning how real and complex numbers are assigned to variables. q Learning how vectors and matrices are assigned values using simple assignment,

More information

MATLAB Fundamentals. Berlin Chen Department of Computer Science & Information Engineering National Taiwan Normal University

MATLAB Fundamentals. Berlin Chen Department of Computer Science & Information Engineering National Taiwan Normal University MATLAB Fundamentals Berlin Chen Department of Computer Science & Information Engineering National Taiwan Normal University Reference: 1. Applied Numerical Methods with MATLAB for Engineers, Chapter 2 &

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

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

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University Part 1 Chapter 2 MATLAB Fundamentals PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

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

PART 1 PROGRAMMING WITH MATHLAB

PART 1 PROGRAMMING WITH MATHLAB PART 1 PROGRAMMING WITH MATHLAB Presenter: Dr. Zalilah Sharer 2018 School of Chemical and Energy Engineering Universiti Teknologi Malaysia 23 September 2018 Programming with MATHLAB MATLAB Environment

More information

Introduction to MATLAB

Introduction to MATLAB to MATLAB Spring 2019 to MATLAB Spring 2019 1 / 39 The Basics What is MATLAB? MATLAB Short for Matrix Laboratory matrix data structures are at the heart of programming in MATLAB We will consider arrays

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

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

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

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

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 Programming Introduction 1 2

Matlab Programming Introduction 1 2 Matlab Programming Introduction 1 2 Mili I. Shah August 10, 2009 1 Matlab, An Introduction with Applications, 2 nd ed. by Amos Gilat 2 Matlab Guide, 2 nd ed. by D. J. Higham and N. J. Higham Starting Matlab

More information

What is Matlab? The command line Variables Operators Functions

What is Matlab? The command line Variables Operators Functions What is Matlab? The command line Variables Operators Functions Vectors Matrices Control Structures Programming in Matlab Graphics and Plotting A numerical computing environment Simple and effective programming

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

Programming in Mathematics. Mili I. Shah

Programming in Mathematics. Mili I. Shah Programming in Mathematics Mili I. Shah Starting Matlab Go to http://www.loyola.edu/moresoftware/ and login with your Loyola name and password... Matlab has eight main windows: Command Window Figure Window

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

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

Outline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline. MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An.

Outline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline. MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An. CSE 170 Interacting with MATLAB Instructor: Aijun An Department of Computer Science and Engineering York University aan@cse.yorku.ca Outline Starting MATLAB MATLAB Windows Using the Command Window Some

More information

Introduction to MATLAB for Engineers, Third Edition

Introduction to MATLAB for Engineers, Third Edition PowerPoint to accompany Introduction to MATLAB for Engineers, Third Edition William J. Palm III Chapter 2 Numeric, Cell, and Structure Arrays Copyright 2010. The McGraw-Hill Companies, Inc. This work is

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

1 Introduction to MATLAB

1 Introduction to MATLAB 1 Introduction to MATLAB 1.1 General considerations The aim of this laboratory is to review some useful MATLAB commands in digital signal processing. MATLAB is one of the fastest and most enjoyable ways

More information

Lecture 2. Arrays. 1 Introduction

Lecture 2. Arrays. 1 Introduction 1 Introduction Lecture 2 Arrays As the name Matlab is a contraction of matrix laboratory, you would be correct in assuming that Scilab/Matlab have a particular emphasis on matrices, or more generally,

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 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

Lab 1 - Worksheet Spring 2013

Lab 1 - Worksheet Spring 2013 Math 300 UMKC Lab 1 - Worksheet Spring 2013 Learning Objectives: 1. How to use Matlab as a calculator 2. Learn about Matlab built in functions 3. Matrix and Vector arithmetics 4. MATLAB rref command 5.

More information

Introduction to MATLAB Programming

Introduction to MATLAB Programming Introduction to MATLAB Programming Arun A. Balakrishnan Asst. Professor Dept. of AE&I, RSET Overview 1 Overview 2 Introduction 3 Getting Started 4 Basics of Programming Overview 1 Overview 2 Introduction

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

Outline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline (Cont d) MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An

Outline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline (Cont d) MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An CSE 170 Interacting with MATLAB Instructor: Aijun An Department of Computer Science and Engineering York University aan@cse.yorku.ca Outline Starting MATLAB MATLAB Windows Using the Command Window Some

More information

Programming in MATLAB

Programming in MATLAB trevor.spiteri@um.edu.mt http://staff.um.edu.mt/trevor.spiteri Department of Communications and Computer Engineering Faculty of Information and Communication Technology University of Malta 17 February,

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

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

Interactive Computing with Matlab. Gerald W. Recktenwald Department of Mechanical Engineering Portland State University

Interactive Computing with Matlab. Gerald W. Recktenwald Department of Mechanical Engineering Portland State University Interactive Computing with Matlab Gerald W. Recktenwald Department of Mechanical Engineering Portland State University gerry@me.pdx.edu Starting Matlab Double click on the Matlab icon, or on unix systems

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

NatSciLab - Numerical Software Introduction to MATLAB

NatSciLab - Numerical Software Introduction to MATLAB Outline 110112 NatSciLab - Numerical Software Introduction to MATLAB Onur Oktay Jacobs University Bremen Spring 2010 Outline 1 MATLAB Desktop Environment 2 The Command line A quick start Indexing 3 Operators

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

Computational Mathematics

Computational Mathematics Computational Mathematics Hilary Term Lecture 1: Programming Andrew Thompson Outline for Today: Schedule this term Review Introduction to programming Examples Arrays: the foundation of MATLAB Basics MATLAB

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 Kristian Sandberg Department of Applied Mathematics University of Colorado Goal The goal with this worksheet is to give a brief introduction to the mathematical software Matlab.

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

OUTLINES. Variable names in MATLAB. Matrices, Vectors and Scalar. Entering a vector Colon operator ( : ) Mathematical operations on vectors.

OUTLINES. Variable names in MATLAB. Matrices, Vectors and Scalar. Entering a vector Colon operator ( : ) Mathematical operations on vectors. 1 LECTURE 3 OUTLINES Variable names in MATLAB Examples Matrices, Vectors and Scalar Scalar Vectors Entering a vector Colon operator ( : ) Mathematical operations on vectors examples 2 VARIABLE NAMES IN

More information

Quick MATLAB Syntax Guide

Quick MATLAB Syntax Guide Quick MATLAB Syntax Guide Some useful things, not everything if-statement Structure: if (a = = = ~=

More information

Ordinary Differential Equation Solver Language (ODESL) Reference Manual

Ordinary Differential Equation Solver Language (ODESL) Reference Manual Ordinary Differential Equation Solver Language (ODESL) Reference Manual Rui Chen 11/03/2010 1. Introduction ODESL is a computer language specifically designed to solve ordinary differential equations (ODE

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

Outline. CSE 1570 Interacting with MATLAB. Outline. Starting MATLAB. MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An.

Outline. CSE 1570 Interacting with MATLAB. Outline. Starting MATLAB. MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An. CSE 10 Interacting with MATLAB Instructor: Aijun An Department of Computer Science and Engineering York University aan@cse.yorku.ca Outline Starting MATLAB MATLAB Windows Using the Command Window Some

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, 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

1.1 ABOUT MATLAB and MATLAB GUI (Graphical User Interface)

1.1 ABOUT MATLAB and MATLAB GUI (Graphical User Interface) Chapter 1 Introduction The Taylor Series is one of the most important tools in numerical analysis. It constitutes the foundation of numerical methods and will be used in most of the chapters of this text.

More information

Introduction to MATLAB programming: Fundamentals

Introduction to MATLAB programming: Fundamentals Introduction to MATLAB programming: Fundamentals Shan He School for Computational Science University of Birmingham Module 06-23836: Computational Modelling with MATLAB Outline Outline of Topics Why MATLAB?

More information

Starting Matlab. MATLAB Laboratory 09/09/10 Lecture. Command Window. Drives/Directories. Go to.

Starting Matlab. MATLAB Laboratory 09/09/10 Lecture. Command Window. Drives/Directories. Go to. Starting Matlab Go to MATLAB Laboratory 09/09/10 Lecture Lisa A. Oberbroeckling Loyola University Maryland loberbroeckling@loyola.edu http://ctx.loyola.edu and login with your Loyola name and password...

More information

Part V Appendices c Copyright, Todd Young and Martin Mohlenkamp, Department of Mathematics, Ohio University, 2017

Part V Appendices c Copyright, Todd Young and Martin Mohlenkamp, Department of Mathematics, Ohio University, 2017 Part V Appendices c Copyright, Todd Young and Martin Mohlenkamp, Department of Mathematics, Ohio University, 2017 Appendix A Glossary of Matlab Commands Mathematical Operations + Addition. Type help plus

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

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

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

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

Creates a 1 X 1 matrix (scalar) with a value of 1 in the column 1, row 1 position and prints the matrix aaa in the command window.

Creates a 1 X 1 matrix (scalar) with a value of 1 in the column 1, row 1 position and prints the matrix aaa in the command window. EE 350L: Signals and Transforms Lab Spring 2007 Lab #1 - Introduction to MATLAB Lab Handout Matlab Software: Matlab will be the analytical tool used in the signals lab. The laboratory has network licenses

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

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

MATLAB Lesson I. Chiara Lelli. October 2, Politecnico di Milano

MATLAB Lesson I. Chiara Lelli. October 2, Politecnico di Milano MATLAB Lesson I Chiara Lelli Politecnico di Milano October 2, 2012 MATLAB MATLAB (MATrix LABoratory) is an interactive software system for: scientific computing statistical analysis vector and matrix computations

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

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

MATLAB Introductory Course Computer Exercise Session

MATLAB Introductory Course Computer Exercise Session MATLAB Introductory Course Computer Exercise Session This course is a basic introduction for students that did not use MATLAB before. The solutions will not be collected. Work through the course within

More information

Dr Richard Greenaway

Dr Richard Greenaway SCHOOL OF PHYSICS, ASTRONOMY & MATHEMATICS 4PAM1008 MATLAB 3 Creating, Organising & Processing Data Dr Richard Greenaway 3 Creating, Organising & Processing Data In this Workshop the matrix type is introduced

More information

1 Introduction to Matlab

1 Introduction to Matlab 1 Introduction to Matlab 1. What is Matlab? Matlab is a computer program designed to do mathematics. You might think of it as a super-calculator. That is, once Matlab has been started, you can enter computations,

More information

MATLAB SUMMARY FOR MATH2070/2970

MATLAB SUMMARY FOR MATH2070/2970 MATLAB SUMMARY FOR MATH2070/2970 DUNCAN SUTHERLAND 1. Introduction The following is inted as a guide containing all relevant Matlab commands and concepts for MATH2070 and 2970. All code fragments should

More information

SECTION 1: INTRODUCTION. ENGR 112 Introduction to Engineering Computing

SECTION 1: INTRODUCTION. ENGR 112 Introduction to Engineering Computing SECTION 1: INTRODUCTION ENGR 112 Introduction to Engineering Computing 2 Course Overview What is Programming? 3 Programming The implementation of algorithms in a particular computer programming language

More information

Learning from Data Introduction to Matlab

Learning from Data Introduction to Matlab Learning from Data Introduction to Matlab Amos Storkey, David Barber and Chris Williams a.storkey@ed.ac.uk Course page : http://www.anc.ed.ac.uk/ amos/lfd/ This is a modified version of a text written

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

A QUICK INTRODUCTION TO MATLAB

A QUICK INTRODUCTION TO MATLAB A QUICK INTRODUCTION TO MATLAB Very brief intro to matlab Basic operations and a few illustrations This set is independent from rest of the class notes. Matlab will be covered in recitations and occasionally

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

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

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

Welcome to EGR 106 Foundations of Engineering II

Welcome to EGR 106 Foundations of Engineering II Welcome to EGR 106 Foundations of Engineering II Course information Today s specific topics: Computation and algorithms MATLAB Basics Demonstrations Material in textbook chapter 1 Computation What is computation?

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

A QUICK INTRODUCTION TO MATLAB. Intro to matlab getting started

A QUICK INTRODUCTION TO MATLAB. Intro to matlab getting started A QUICK INTRODUCTION TO MATLAB Very brief intro to matlab Intro to matlab getting started Basic operations and a few illustrations This set is indepent from rest of the class notes. Matlab will be covered

More information

Introduction to Matlab. By: Hossein Hamooni Fall 2014

Introduction to Matlab. By: Hossein Hamooni Fall 2014 Introduction to Matlab By: Hossein Hamooni Fall 2014 Why Matlab? Data analytics task Large data processing Multi-platform, Multi Format data importing Graphing Modeling Lots of built-in functions for rapid

More information

MATLAB Basics. Mohamed Taha. Communication Engineering Department Princess Sumaya University Page 1 of 32. Full Screen.

MATLAB Basics. Mohamed Taha. Communication Engineering Department Princess Sumaya University Page 1 of 32. Full Screen. Mohamed Taha Communication Engineering Department Princess Sumaya University mtaha@psut.edu.jo Page 1 of 32 1 What is It is an abbreviation to MATrix LABoratory Front end for a matrix library It is an

More information

Lecture 1: What is MATLAB?

Lecture 1: What is MATLAB? Lecture 1: What is MATLAB? Dr. Mohammed Hawa Electrical Engineering Department University of Jordan EE201: Computer Applications. See Textbook Chapter 1. MATLAB MATLAB (MATrix LABoratory) is a numerical

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

Computer Programming in MATLAB

Computer Programming in MATLAB Computer Programming in MATLAB Prof. Dr. İrfan KAYMAZ Atatürk University Engineering Faculty Department of Mechanical Engineering What is a computer??? Computer is a device that computes, especially a

More information

AMS 27L LAB #1 Winter 2009

AMS 27L LAB #1 Winter 2009 AMS 27L LAB #1 Winter 2009 Introduction to MATLAB Objectives: 1. To introduce the use of the MATLAB software package 2. To learn elementary mathematics in MATLAB Getting Started: Log onto your machine

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

Lecture 15 MATLAB II: Conditional Statements and Arrays

Lecture 15 MATLAB II: Conditional Statements and Arrays Lecture 15 MATLAB II: Conditional Statements and Arrays 1 Conditional Statements 2 The boolean operators in MATLAB are: > greater than < less than >= greater than or equals

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

Finding, Starting and Using Matlab

Finding, Starting and Using Matlab Variables and Arrays Finding, Starting and Using Matlab CSC March 6 &, 9 Array: A collection of data values organized into rows and columns, and known by a single name. arr(,) Row Row Row Row 4 Col Col

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

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

MATLAB. A Tutorial By. Masood Ejaz

MATLAB. A Tutorial By. Masood Ejaz MATLAB A Tutorial By Masood Ejaz Note: This tutorial is a work in progress and written specially for CET 3464 Software Programming in Engineering Technology, a course offered as part of BSECET program

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

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

MATLAB BASICS. M Files. Objectives

MATLAB BASICS. M Files. Objectives Objectives MATLAB BASICS 1. What is MATLAB and why has it been selected to be the tool of choice for DIP? 2. What programming environment does MATLAB offer? 3. What are M-files? 4. What is the difference

More information

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

An Introduction to MATLAB and the Control Systems toolbox Aravind Parchuri, Darren Hon and Albert Honein E205 Introduction to Control Design Techniques An Introduction to MATLAB and the Control Systems toolbox Aravind Parchuri, Darren Hon and Albert Honein MATLAB is essentially a programming interface that

More information