Professional Documents
Culture Documents
MATLAB Script Notes
MATLAB Script Notes
MATLAB Script Notes
===================================================================================
=======
--------------------------------------------------------------MATLAB commands and
notes------------------------------------------------------------------------------
--------
===================================================================================
===================================================================================
=======
*matrix
>>A = [1 2 3 4] %creates a 1x4 matrix with data
>>B = [1,2,3,4] %also creates a 1x4 matrix with data
>>C = [5;6;7;8] %creates 4x1 matrix with data
>>D = [1 2 3 4; 5 6 7 8; 9 10 11 12] %creates a 4x3 matrix
>>A = [5 2 1; 1 1 2; 2 -1 0]
>>B = [30; 27; -1]
>>s = inv(A)*B %using inverse
%OR
>>s = A\B %using matrix division
%OR
>>augmented = [A B] %creates augmented matrix
>>reduced_augmented = rref(augmented) %reduces augmented matrix
>>s = reduced_augmented(: , 4) %gives answer to s
*complex numbers
>>V_magnitude = abs(V) %assigns the magnitude of V
>>V_angle = angle(V) %assigns the angle of V
*plots
>>plot (x,y) %plots x versus y. X AND Y MUST HAVE SAME
LENGTH.
>>title('Lab 1') %puts a title
>>xlabel('Voltage') %puts an x-axis title
>>ylabel('Current') %puts an y-axis title
>>axis([xmin, xmax, ymin, ymax]) %makes limit for the axis
>>grid %puts grid lines in graph