You are on page 1of 2

Lab 1

Introduction to Matlab:
Matlab stands for matrix laboratory
it means everything is stored in the form of matrices.
There are three wndows:
1)Command window
2)Current folder
3)workspace
We will use different commands:
Create a variable
x=10;
y=10
To find size of a vector:
a=[1 2 3 4 5]
size(a)=1 5
w=[1;2;3;4;5]
size(w)=5 1
z=[1 2;3 4]
size(z)= 2 2
b= [ 1 2 3 4 5;6 7 8 9 10;11 12 13 14
15]
size(b)=3 5
b(2,4)
b(2,:) display 2nd row
b(:,4) display 4th col
b(:,:) display overall matrix
b(2:3,2:4) display element of 2nd and
3rd row from 2nd to 4th column
c=1:10 store value from 1 to 10
d=1:2:1000; store value from 1 to 1000
with step size 2.
e=[1;5]
e' it means Transpose
f=[1 3; 2 4]
g=[1 4 ; 1 3]
f+g addition of two matrices
f*g multiplication of 2 matrices
f/3 division of a matrix by a constant
number
f-e subtraction of two matrices
g=[1 2 3]
h=[4 5 6]
dot(g,h) dot product
cross(g,h) cross product
pi constant number
j=5+6i
k=4+2i
j/k simple division of two complex
numbers.
log(10) log of a number
sqrt(-1) square root of a number.
sqrt(-5)

You might also like