MATLAB Quick Guide Symbol/ Command Name Description Example help help Help menu for any command or symbol in MATLAB Help : Help sum % comment MATLAB comment symbol; MATLAB will skip any line beginning with the % symbol a = 1 % comments here… % this will all % be ignored! % except for the a = 1 * multiply Symbol for multiplication a = 5 * 5 ; / divide Symbol for division b = 5 / 1 ; ; semi-colon (1) Tells MATLAB to suppress the output (do not print value, equation, etc. to screen) (2) Also used to separate rows in a matrix a = 2 ; b = 5 * a + 2 + a ; A = [ 1 , 2 , 3 ; 4 , 2 , 0 ] ; plot plot Plot a 2-D grapth (x-y) plot(x,y,’o’) clear clear Clears all variables in memory; if given an argument(s), will just clear those specified variables clear clear f, g, h, j clc command line clear Will clear the command line display, but will not erase memory clc You will be given a clean command line fopen fprintf fclose fopen, printf, close Commands for opening a file, printing to it, and closing the file See examples in Lab. hist( ) histogram Command for plotting a histogram from the input values j = hist( g ) ; ^ caret, hat “Raised to the power of”… c = a .^ 2 ; sqrt( ) square root Command for computing the square root e = sqrt( c ) ; pi π Mathematical symbol for 3.1415926.. a = pi ; whos whos Command that lists all of the variables defined in your current MATLAB session whos Prints information for a b c A C e, etc. inv( ) inverse Computes the inverse of a matrix D = inv( C ) ; ' transpose Computes the transpose of a matrix, shortcut for transpose(x) D = C’ ; D = transpose( C ) ;zeros(m,n) zeros Command for defining an m x n matrix of zeros E = zeros( 2 , 2 ) ; ones(m,n) ones Command for defining an m x n matrix of ones E = ones( 2 , 2 ) ; size( ) size Command for printing the number of rows and columns of a vector or matrix size( E ) ; sum( ) sum Command for summing all of the elements of a given vector f = sum( 3 , 2 , 1 ) ; min , max min, max Command for printing the minimum or maximum values in a vector. g = min( 3 , 2 , 1 ) ; h = max( 3 , 2 , 1 ) ; imagesc imagesc Command for plotting a 2-D array of values imagesc( E ) help graph3d Help menu and command list for many graphing features (includes
View Full Document