6 Matrix
Square brackets delimit literal matrices. Commas separate elements on the same row. Semicolons separate rows. Commas may be replaced by spaces, and semicolons may be replaced by newlines. Elements of a matrix may be arbitrary expressions, assuming all the dimensions agree.
| octave | description |
|---|---|
[ x, y, ... ] |
enter a row vector |
[ y; y; ... ] |
enter a column vector |
[ w, x; y, z ] |
enter a 2x2 matrix |
rows columns |
number of rows / comlumns of matrix |
zeros ones |
create matrix of zeros / ones |
eye diag |
create identity / diagonal matrix |
rand randi randn |
create matrix of random values |
all |
true if all elements nonzero |
any |
true if at least one element nozero |
nnz |
number of nonzero elements |