# Basic Matlab

Matlab is the most powerful example of numerical linear algebra software. It has some symbolic capabilities, but here we describe only the most basic aspects of matrix and vector handling. Simple examples of these procedures follow.

- Define row vector:

`x=[1 2 3 4 5]` - Define column vector:

`y=[1`

2

3

4

5]

or

`y=[1;2;3;4;5]` - Vector multiplication:

`x*y`gives 55;`y*x`gives a 5×5 matrix. - Elementwise multiplication and exponentiation:

`[1 2] .* [1 2]`gives`[1 4]`

`[1 2] .^ 2`gives`[1 4]` - Define matrix:

`A = [1 2`

3 4]

or

`A=[1 2; 3 4]` - Transpose of a matrix or vector

`A'` - Multiplication:

`A*[1;2]` - Subtraction:

`x-y'` - Matrix inverse:

`inv(A)` - Identity matrix of dimension N:

`eye(N)` - Zero matrix of dimension m by n:

`zeros(m,n)` - Constant matrix of dimension m by n

`anumber * ones(m,n)` - Previous commands: use the up-arrow key to get commands entered earlier. Use the left arrow and backspace keys to move and delete from those commands, so you can modify them.
- Variable list: the
`who`command lists all the variables that are currently defined. - Help: typing
`help commandname`gives a page of help about the command called`commandname.`