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 "final exam" for this course will take place at 8:00 AM on Tuesday, 12 December. This will be an ordinary 50 minute test. It will be comprehensive, but weighted toward the latter half of the semester. As always, paper notes will be permitted, but no electronic devices will be allowed.

A Solution example is available for the quiz.

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