Lab 1
Lab 1
INTRODUCTION
Keeps record
of previously
used commands
Figure Window
Commands
• save
• clc
• clear
• help
Important Points
• MATLAB is case sensitive.
• For comment: %.
Concatenating a row
Number of columns in both
must be same
Concatenating a column
Number of rows in both must
be same
COLON OPERATOR (:)
Two types of formats used
Starting value : Ending value
e.g. j:k => [j j+1 j+2 … k]
Starting value: Step size: Ending value
e.g. j:s:k => [j j+s j+2s … k]
If step size is not entered, it is ‘1’ by default
as in the first format.
ACCESSING MATRIX ENTITIES
Accessing a certain row => A(m1,:)
‘m1’ => select a certain row
‘:’ =>select all columns
1 2 3 4 5 6 7 8 9 10
DELETING ENTRIES
There are two methods of deleting entries
from a matrix
1 4 7
Indicating rows and columns 2 5 8
1. Similar like accessing entities (see 3 6 9
lecture 1)
2. Syntaxes: A(m1,:)=[], A(:,n1)=[].
Using indexes
A(j:s:k)=[]; The remaining entities
are reshaped into a row vector.
Remember: A(m1,n1)=[] will result in an
error since the result is not a matrix
anymore.
SPECIAL VARIABLES
ans : The default variable used for the most recent result. This variable is
also used as a default variable to store any value.
eps : The smallest number such that when added to 1 creates a number
greater than 1
‘i’ or ‘j’ : I or j =
OTHER USEFUL COMMANDS
TRY YOURSELF