MATLAB stands for MATrix LABoratory. Introduction MATLAB stands for MATrix LABoratory. Basics Matrix Manipulations MATLAB Programming Graphics Image types Image Processing Useful functions
Basics Basic data element is an array that does not require dimensioning. A=[1 2 3;4 5 6; 7 8 9] A = [ 1 2 3 4 5 6 7 8 9]
Matrix Manipulations Sum(A) = sums of the columns of A A’ = Transpose of A Diag(A) = gives diagonal elements of A Min(A) = minimum element column wise of A. Max(A) = maximum element column wise of A. Mean(A) = Average element column wise of A. Std(A) = Standard deviation column wise of A. X = zeros(5,5) Y = ones(6,6) M=rand(5,5) N = randn(6,6) A=[1:50] A=[0:pi/4:pi]=[0 0.7854 1.5708 2.3562 3.1416]
Matrix Manipulations (contd..) B = magic(4) = [ 16 2 3 13 Dürer's magic square 5 11 10 8 9 7 6 12 4 14 15 1] All numbers are stored internally using the long format specified by the IEEE floating-point standard. Floating-point numbers have finite precision 16 significant decimal digits and finite range 10-308 to 10+308.
Matrix Manipulations (contd..) A(:,2) = [] deletes 2nd column. A(2:2:12) = [] results in row vector of remaining elements. A = A.*5 Element-by-element multiplication. [indices] = find(isprime(A)) format this command can be used for formatting the displayed numeric output (either in short or long format).
MATLAB Programming MATLAB has several flow control constructs: if statements switch statements for loops while loops continue statements break statements
Graphics Plotting sinusoidal function using the plot function. Cylinder unit cylinder with default 20 points on the circumference. Sphere unit sphere with default 20 points on the circumference. Subplot(m,n,p) partitions the figure window into m-by-n matrix of small subplots and selects the pth subplot for the current plot.
Graphics (contd..) mesh produces wire frame surfaces that color only the lines connecting the defining points. surf displays both the connecting lines and the faces of the surface in color. Light and camera effect on the visualization of 2-dim sinc function (i.e. sin(r)/r) between x and y directions.
Types of Images Index images Intensity images Binary images RGB images
Image Processing Dürer's magic square Animation using EraseMode property. Animation using Movie method Functions: Imread read an image Imwrite writes specified matrix into an image. Image displays specified matrix as an image. Imshow Displays an intensity (gray level) image. Im2frame converts an image into movie frame. Avifile creates an avifile object. Addframe adds movie frame to avifile object. Getframe returns movie frame. Movie Play recorded movie frames. close closes current figure.
Useful functions help fnName help on any function. whos information on current variables in the workspace. guide GUI editor. demo Matlab toolboxes and functions demo. eval(str) evaluates expression in the str variable. load abc.mat loads data in the matlab file.