





































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A quick tutorial on using matlab, a software package for numerical computation. Topics covered include matlab's origins, variable names and special variables, relational and logical operators, matrices and matrix manipulation functions, and matlab's built-in math functions. This tutorial is suitable for both beginners and those looking to refresh their knowledge.
Typology: Lab Reports
1 / 45
This page cannot be seen from the preview
Don't miss anything!






































Note: Unlike C, MATLAB’s indices start from 1
Example :
X = [1 , 2 , 3 ; 4 , 5 , 6 ; 7 , 8 , 9] X = 1 2 3 4 5 6 7 8 9
X22 = X(1:2 , 2:3)
X22 = 2 3 5 6
>> a = [1,2i,0.56] a = 1 0+2i 0.
a(2,4) = 0. a = 1 0+2i 0.56 0 0 0 0 0.
repmat – replicates and tiles a matrix
b = [1,2;3,4] b = 1 2 3 4 b_rep = repmat(b,1,2) b_rep = 1 2 1 2 3 4 3 4
Concatenation
a = [1,2;3,4] a = 1 2 3 4 a_cat =[a,2a;3a,2*a] a_cat = 1 2 2 4 3 4 6 8 3 6 2 4 9 12 6 8
NOTE: The resulting matrix must be rectangular
Matrix multiplication
a = [1,2;3,4]; (2x2) b = [1,1]; (1x2) c = b*a c = 4 6
c = a*b ??? Error using ==> mtimes Inner matrix dimensions
must agree.
Element wise multiplication
a = [1,2;3,4]; b = [1,½;1/3,¼]; c = a.*b c = 1 1
1 1
Matrix Element wise operations
>> a = [1,2;1,3];
b = [2,2;2,1];
Element wise division
c = a./b c = 0.5 1 0.5 3
Element wise multiplication
c = a.*b c = 2 4 2 3
Element wise power operation
c = a.^ c = 1 4 1 9
c = a.^b c = 1 4 1 3
MATLAB inbuilt math functions