# 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.

The last test will take place at the final exam time on Tuesday, 12 December, from 1:30-3:30. It will be written as a one-hour (not 50 minute) exam, but you may have the full two hours for it. In other respects it will be very like the other tests, but comprehensive - it will emphasize Python, but cover all the topics we have seen.

Assignment A is posted.

Department of Mathematics, PO Box 643113, Neill Hall 103, Washington State University, Pullman WA 99164-3113, 509-335-3926, Contact Us