matlab-basic-functions-reference.pdf
Create vector of n equally spaced values logspace(ab
matlab basic functions reference
APUNTES MATLAB
logspace - Logarithmically spaced vector. freqspace - Frequency spacing for frequency response. meshgrid - X and Y arrays for 3-D plots.
APUNTES MATLAB
MATLAB Commands and Functions
Matrix Commands for Solving Linear Equations / 6 Lists all MATLAB files in the current directory. wklread ... Creates logarithmically spaced vector.
MatlabCommands
MATLAB® Basic Functions Reference
mathworks.com/help/matlab. MATLAB® Basic Functions Reference Defining and Changing Array Variables ... Create vector of n logarithmically spaced.
matlab basic functions reference
INTRODUCTION TO MATLAB FOR ENGINEERING STUDENTS
4 Introduction to programming in MATLAB log10(x) Common logarithm conj(x) ... generates a row vector y of 100 points linearly spaced between and ...
introduction to matlab
PROGRAMACI´ON EN MATLAB
3 oct de 2014 vamente la estructura de datos central de MATLAB: el array. ... cuada para introducir el vector—también es capaz de leer matrices.
apuntesMATLAB
Untitled
Matlab. • Cosa è Matlab. • L'ambiente a riga di comando Information about MATLAB and The MathWorks. ... Logarithmically spaced vector.
Matlab.Introduzione
matlab-help-text asec acsc cot acot exp log logic sqrt abs angle conj
Logarithmically spaced vector. meshgrid. - X and Y arrays for 3-D plots. : - Regularly spaced vector and index into matrix. Basic array information.
Matlab help text
Matlab Sheet 2 Arrays
Matlab Sheet 2 Solution. Matlab Sheet 2. Arrays. 1. a. Create the vector x having 50 logarithmically spaced values starting at. 10 and ending at 1000.
Matlab Sheet solution
Programing the Finite Element Method with Matlab
3 oct de 2002 following Matlab code which sets the row and column of a matrix A to zero ... Logarithmically spaced vector. meshgrid.
matlab fem
INTRODUCTION TO MATLAB FOR
ENGINEERING STUDENTS
David Houcque
Northwestern University
(version 1.2, August 2005)Contents
1Tutorial lessons 1
1 1.1Introduction
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2Basic features
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.3A minimum MATLAB session
. . . . . . . . . . . . . . . . . . . . . . . . . . 21.3.1 Starting MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3.2 Using MATLAB as a calculator . . . . . . . . . . . . . . . . . . . . . 4
1.3.3 Quitting MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.4Getting started
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.4.1 Creating MATLAB variables . . . . . . . . . . . . . . . . . . . . . . . 5
1.4.2 Overwriting variable . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.4.3 Error messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.4.4 Making corrections . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.4.5 Controlling the hierarchy of operations or precedence . . . . . . . . . 6
1.4.6 Controlling the appearance of °oating point number . . . . . . . . . . 8
1.4.7 Managing the workspace . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.4.8 Keeping track of your work session . . . . . . . . . . . . . . . . . . . 9
1.4.9 Entering multiple statements per line . . . . . . . . . . . . . . . . . . 9
1.4.10 Miscellaneous commands . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.4.11 Getting help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.5Exercises
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2Tutorial lessons 2
12 2.1Mathematical functions
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.1.1 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
i 2.2Basic plotting
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142.2.1 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.2.2 Creating simple plots . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.2.3 Adding titles, axis labels, and annotations . . . . . . . . . . . . . . . 15
2.2.4 Multiple data sets in one plot . . . . . . . . . . . . . . . . . . . . . . 16
2.2.5 Specifying line styles and colors . . . . . . . . . . . . . . . . . . . . . 17
2.3Exercises
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.4Introduction
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 2.5Matrix generation
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192.5.1 Entering a vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.5.2 Entering a matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.5.3 Matrix indexing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.5.4 Colon operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.5.5 Linear spacing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.5.6 Colon operator in a matrix . . . . . . . . . . . . . . . . . . . . . . . . 22
2.5.7 Creating a sub-matrix . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.5.8 Deleting row or column . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.5.9 Dimension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.5.10 Continuation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.5.11 Transposing a matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.5.12 Concatenating matrices . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.5.13 Matrix generators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.5.14 Special matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.6Exercises
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 3Array operations and Linear equations
303.1
Array operations
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303.1.1 Matrix arithmetic operations . . . . . . . . . . . . . . . . . . . . . . . 30
3.1.2 Array arithmetic operations . . . . . . . . . . . . . . . . . . . . . . . 30
3.2 Solving linear equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.2.1 Matrix inverse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
ii3.2.2 Matrix functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.3Exercises
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 4Introduction to programming in MATLAB
354.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.2 M-File Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.2.1 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
4.2.2 Script side-e®ects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.3 M-File functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
4.3.1 Anatomy of a M-File function . . . . . . . . . . . . . . . . . . . . . . 38
4.3.2 Input and output arguments . . . . . . . . . . . . . . . . . . . . . . . 40
4.4 Input to a script ¯le . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
4.5 Output commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.6Exercises
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 5Control °ow and operators
435.1
Introduction
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 5.2Control °ow
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435.2.1 The``if...end''structure . . . . . . . . . . . . . . . . . . . . . . . 43
5.2.2 Relational and logical operators . . . . . . . . . . . . . . . . . . . . . 45
5.2.3 The``for...end''loop . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.2.4 The``while...end''loop . . . . . . . . . . . . . . . . . . . . . . . 46
5.2.5 Other °ow structures . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.2.6 Operator precedence . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
5.3Saving output to a ¯le
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 5.4Exercises
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 6Debugging M-¯les
496.1
Introduction
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 6.2INTRODUCTION TO MATLAB FOR
ENGINEERING STUDENTS
David Houcque
Northwestern University
(version 1.2, August 2005)Contents
1Tutorial lessons 1
1 1.1Introduction
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2Basic features
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.3A minimum MATLAB session
. . . . . . . . . . . . . . . . . . . . . . . . . . 21.3.1 Starting MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3.2 Using MATLAB as a calculator . . . . . . . . . . . . . . . . . . . . . 4
1.3.3 Quitting MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.4Getting started
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.4.1 Creating MATLAB variables . . . . . . . . . . . . . . . . . . . . . . . 5
1.4.2 Overwriting variable . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.4.3 Error messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.4.4 Making corrections . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.4.5 Controlling the hierarchy of operations or precedence . . . . . . . . . 6
1.4.6 Controlling the appearance of °oating point number . . . . . . . . . . 8
1.4.7 Managing the workspace . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.4.8 Keeping track of your work session . . . . . . . . . . . . . . . . . . . 9
1.4.9 Entering multiple statements per line . . . . . . . . . . . . . . . . . . 9
1.4.10 Miscellaneous commands . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.4.11 Getting help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.5Exercises
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2Tutorial lessons 2
12 2.1Mathematical functions
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.1.1 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
i 2.2Basic plotting
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142.2.1 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.2.2 Creating simple plots . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.2.3 Adding titles, axis labels, and annotations . . . . . . . . . . . . . . . 15
2.2.4 Multiple data sets in one plot . . . . . . . . . . . . . . . . . . . . . . 16
2.2.5 Specifying line styles and colors . . . . . . . . . . . . . . . . . . . . . 17
2.3Exercises
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.4Introduction
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 2.5Matrix generation
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192.5.1 Entering a vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.5.2 Entering a matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.5.3 Matrix indexing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.5.4 Colon operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.5.5 Linear spacing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.5.6 Colon operator in a matrix . . . . . . . . . . . . . . . . . . . . . . . . 22
2.5.7 Creating a sub-matrix . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.5.8 Deleting row or column . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.5.9 Dimension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.5.10 Continuation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.5.11 Transposing a matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.5.12 Concatenating matrices . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.5.13 Matrix generators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.5.14 Special matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.6Exercises
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 3Array operations and Linear equations
303.1
Array operations
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303.1.1 Matrix arithmetic operations . . . . . . . . . . . . . . . . . . . . . . . 30
3.1.2 Array arithmetic operations . . . . . . . . . . . . . . . . . . . . . . . 30
3.2 Solving linear equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.2.1 Matrix inverse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
ii3.2.2 Matrix functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.3Exercises
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 4Introduction to programming in MATLAB
354.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.2 M-File Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.2.1 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
4.2.2 Script side-e®ects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.3 M-File functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
4.3.1 Anatomy of a M-File function . . . . . . . . . . . . . . . . . . . . . . 38
4.3.2 Input and output arguments . . . . . . . . . . . . . . . . . . . . . . . 40
4.4 Input to a script ¯le . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
4.5 Output commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.6Exercises
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 5Control °ow and operators
435.1
Introduction
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 5.2Control °ow
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435.2.1 The``if...end''structure . . . . . . . . . . . . . . . . . . . . . . . 43
5.2.2 Relational and logical operators . . . . . . . . . . . . . . . . . . . . . 45
5.2.3 The``for...end''loop . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.2.4 The``while...end''loop . . . . . . . . . . . . . . . . . . . . . . . 46
5.2.5 Other °ow structures . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.2.6 Operator precedence . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
5.3Saving output to a ¯le
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 5.4Exercises
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 6Debugging M-¯les
496.1
Introduction
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 6.2- logarithmically spaced vector matlab
- log spaced vector matlab