Top 10 Matlab Commands for Linear Algebra Students
- basic input: "A = [ 1 2 3; -1 2 3; 2 4 5 ]" inputs a 3x3 matrix by rows;
variants
"b = [ -1 2 1]' " or "b = [ -1; 2; 1]" to input a column vector b, and
"C = [ A b ]" to produce a matrix C containing A augmented with b.
Note: "format compact" reduces output spaces; also try
"format long", "format rat", "help format".
- rref: "rref(A)" reduces A to reduced echelon form; see also
"rrefmovie(A)".
- basic arithmetic: "A*B", "A+B", "A\b" to multiply and add matrices,
solve Ax = b.
- help: "help command" gives information about "command", e.g. "help rref".
Note: "more on" gives output (e.g. from help) one screen at a time.
- lookfor: "lookfor keyword" tries to find commands relevant to "keyword";
e.g. "lookfor null".
- diary: "diary myfile" records subsequent output in the file "myfile" for
printing later;
"diary off" stops the recording;
"!mail name@email.address < myfile" emails "myfile" to "name@email.address"
from a computer with a Unix OS.
- rand: "rand(6,4)" produces a random 6x4 matrix.
- det: "det(A)" computes the determinant of a square matrix A.
- inv: "inv(A)" tries to compute the inverse of a square matrix A.
- eig: "eig(A)" computes eigenvalues(vectors) for square A; try
"help eig" for more info.
Note: the uparrow key gives previous commands that may be edited to save
typing; this only works if your keyboard characterstics are properly
recognized.