MATLAB ……………….matrix laboratory. Bhushan D Patil PhD Research Scholar Department of Electrical Engineering Indian Institute of Technology, Bombay Powai, Mumbai
What is MATLAB? MATLAB is a high-performance language for technical computing. It integrates computation, visualization, and programming in an easy-to- use environment where problems and solutions are expressed in familiar mathematical notation. Typical uses include Math and computation Algorithm development Data acquisition Modeling, simulation, and prototyping Data analysis, exploration, and visualization Scientific and engineering graphics Application development, including graphical user interface building
Starting and Quitting MATLAB Starting MATLAB Quitting MATLAB MATLAB Desktop
Editor/Debugger
Array Editor
Matrices and Arrays A = [ ; ; ; ] A = sum, transpose, and diag sum(A) ans = A‘ ans = diag(A) ans =
Generating Basic Matrices zeros All zeros Z = zeros(2,4) Z = 0 0 ones All ones F = 5*ones(3,3) F = rand Uniformly distributed random elements N = fix(10*rand(1,10)) N = randn Normally distributed random elements R = randn(4,4) R =
Concatenation B = [A A+32; A+48 A+16] B = Deleting Rows and Columns X = A; X(:,2) = [] X = inv(A) eig(A)
Subscripts A(1,4) + A(2,4) + A(3,4) + A(4,4) The Colon Operator 1:10 ans :-7:50 ans :pi/4:pi ans
The list of operators includes + Addition - Subtraction.* Element-by-element multiplication./ Element-by-element division.\ Element-by-element left division.^ Element-by-element power
Graphics
Figure Tools
Preparing Graphs x = -10:.005:40; y = [1.5*cos(x)+4*exp(-.01*x).*cos(x)+exp(.07*x).*sin(3*x)]; plot(x,y)
Multiple Data Sets in One Graph x = 0:pi/100:2*pi; y = sin(x); y2 = sin(x-.25); y3 = sin(x-.5); plot(x,y,x,y2,x,y3) legend('sin(x)','sin(x-.25)','sin(x-.5)')
Mesh and Surface Plots [X,Y] = meshgrid(-8:.5:8); R = sqrt(X.^2 + Y.^2) + eps; Z = sin(R)./R; mesh(X,Y,Z,'EdgeColor','black')
Programming if, else, and elseif if A > B 'greater' elseif A < B 'less' elseif A == B 'equal' else error('Unexpected situation') end switch and case switch (rem(n,4)==0) + (rem(n,2)==0) case 0 M = odd_magic(n) case 1 M = single_even_magic(n) case 2 M = double_even_magic(n) otherwise error('This is impossible') end
For for n = 3:32 r(n) = rank(magic(n)); end Nested for for i = 1:m for j = 1:n H(i,j) = 1/(i+j); end while While(i<25) a=a+2; end break
Toolbox available Communications Control System Curve Fitting Fuzzy Logic Image Processing Instrument Control Robust Control Signal Processing System Identification Virtual Reality Wavelet