User:Eml4500.f08.ateam.shah/Section5

Section 5: Matrix Building Function
Matrix building functions are

eye	       identity matrix zeros          matrix of zero ones           matrix of ones diag           create or extract diagonals triu           upper triangular part of the matrix tril           lower triangular part of the matrix rand           randomly generated matrix hilb           Hilbert Matrix magic          magic square topelitz       see help topelitz

Functions like zeros, eye, and ones can be used to create matrices. The functions are followed by the size of the matrix.

Ex:

$$>> zeros(2,3)$$ $$ans =$$ 0    0     0     0     0     0 Functions such as diagonals vectors require a vector as an input.

Ex:

$$>>A =$$ 2    2     2     2

$$>> diag(A)$$ $$ans = $$    2     2

You can combine and create new matrices using multiple functions.

Ex: This function will create a 5x5 matrix shown below.

$$>> 	B= [A, zeros(3,2); zeros(2,3), eye(2)]$$

$$B =$$

0    0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     1     0     0     0     0     0     1