3 Getting Help from Within MATLAB If you know the name of a function which you would like to learn how to use, use the help command > help functionname This command displays a description of the function and generally also includes a list of related functions. If you cannot remember the name of the function, use the lookfor' command and the name of some keyword associated with the function > lookfor keyword This command will display a list of functions that include the keyword in their descriptions Other help commands that you may find useful are ' info, what, andwhich. descrip- tions of these commands can be found by using the help command. MATLAB also contains a variety of demos that can be with the 'demo'command 4 MATLAB Variables- Scalars. Vectors, and matri ces MATLAB Stores variables in the form of matrices which are mxn where m is the number of rows and n the number of columns. a 1 x1 matrix is a scalar: a 1xn matrix is a row vector, and M xl matrix is a column vector. All elements of a matrix can be real or complex numbers;v-I can be written as either"i'orj' provided they are not redefined by the user A matrix is written with a square bracket '[]' with spaces separating adjacent columns and semicolons separating adjacent rows. For example, consider the following assignments of the variable x Real scalar >>x=5 Complex scalar >>x=5+10j(or >>x=5+101) [123]( Column vector >>x= [1; 2: 3] 3 matrix>>x=[123;456;789 There are a few notes of caution. Complex elements of a matrix should not be typed with spaces, i.e., -1+2j is fine as a matrix element, -1 2j is not. Also, -1+2j is interpreted correctly whereas -1+j2 is not(MATLAB interprets the j2' as the name of a variable You can always write-1+j*2 4.1 Complex number operations Some of the important operations on complex numbers are illustrated below3 Getting Help from Within MATLAB If you know the name of a function which you would like to learn how to use, use the ‘help’ command: >> help functionname This command displays a description of the function and generally also includes a list of related functions. If you cannot remember the name of the function, use the ‘lookfor’ command and the name of some keyword associated with the function: >> lookfor keyword This command will display a list of functions that include the keyword in their descriptions. Other help commands that you may find useful are ‘info’, ‘what’, and ‘which’. Descriptions of these commands can be found by using the help command. MATLAB also contains a variety of demos that can be with the ‘demo’ command. 4 MATLAB Variables — Scalars, Vectors, and Matrices MATLAB stores variables in the form of matrices which are M ×N, where M is the number of rows and N the number of columns. A 1 × 1 matrix is a scalar; a 1 × N matrix is a row vector, and M ×1 matrix is a column vector. All elements of a matrix can be real or complex numbers; √−1 can be written as either ‘i’ or ‘j’ provided they are not redefined by the user. A matrix is written with a square bracket ‘[]’ with spaces separating adjacent columns and semicolons separating adjacent rows. For example, consider the following assignments of the variable x Real scalar >> x = 5 Complex scalar >> x = 5+10j (or >> x = 5+10i) Row vector >> x = [1 2 3] (or x = [1, 2, 3]) Column vector >> x = [1; 2; 3] 3 × 3 matrix >> x = [1 2 3; 4 5 6; 7 8 9] There are a few notes of caution. Complex elements of a matrix should not be typed with spaces, i.e., ‘-1+2j’ is fine as a matrix element, ‘-1 + 2j’ is not. Also, ‘-1+2j’ is interpreted correctly whereas ‘-1+j2’ is not (MATLAB interprets the ‘j2’ as the name of a variable. You can always write ‘-1+j*2’. 4.1 Complex number operations Some of the important operations on complex numbers are illustrated below 4