Introduction to MATLABMorrisLawMarch 21.2018
1 Introduction to MATLAB Morris Law March 21, 2018
OutlineMatlabsoftwareEntering matrixMatrix function and manipulationMatlab graphicsMatlab programming: writing M-file andfunctionsFunction input & outputControl flow
2 Outline ◼ Matlab software ◼ Entering matrix ◼ Matrix function and manipulation ◼ Matlab graphics ◼ Matlab programming: writing M-file and functions ◼ Function input & output ◼ Control flow
MATLAB softwareMulti-platforms (Windows,Linux, MacOsX)Technical computingScript languageVariablesare all matricesExpandablebyaddingtoolboxes
3 MATLAB software ◼ Multi-platforms (Windows, Linux, MacOSX) ◼ Technical computing ◼ Script language ◼ Variables are all matrices ◼ Expandable by adding toolboxes
Entering matrixExplicit listing>>A = [1,2,3; 4,5, 6;7 8 9]M-fileStored the above statement in ex1 .m. Run theM-file, i.e. >> ex1External data files>> load A.datBuilt-in statements and functions>> B = eye(3)
4 Entering matrix ◼ Explicit listing >> A = [1, 2, 3; 4, 5, 6; 7 8 9] ◼ M-file Stored the above statement in ex1.m. Run the M-file, i.e. >> ex1 ◼ External data files >> load A.dat ◼ Built-in statements and functions >> B = eye(3)
Matrix function and manipulationones(3), zeros(3), eye(3)magic(4), hilb(5), rand(4,3)size(A), eig(A), det(A), inv(A), diag(A)sum(A), prod(A), mean(A), max(A), std(A)
5 Matrix function and manipulation ◼ ones(3), zeros(3), eye(3) ◼ magic(4), hilb(5), rand(4,3) ◼ size(A), eig(A), det(A), inv(A), diag(A) ◼ sum(A), prod(A), mean(A), max(A), std(A)