1. Building Matrices

Matlab has many types of matrices which are built into the system. Try

rand(7)
rand(2,5)
help rand

Another special matrix is the Hilbert matrix:

hilb(5)
help hilb

A 5×5 magic square is given by

magic(5)
help magic

Here are some standard matrices from linear algebra:

eye(6)
zeros(4,7)
ones(5)

You can build matrices several ways. Try

[1 2 3 5 7 9]
[1, 2, 3; 4, 5, 6; 7, 8, 9]
[1 2 (return) 3 4 (return) 5 6]

Here (return) is the Return or Enter key. Try these:

[eye(2); zeros(2)]
[eye(2); zeros(3)]
Did you get an error message? Why? Now try

[eye(2), ones(2,3)]


Next Section: 2. Functions


Created by F.G. Garvan (fgarvan@ufl.edu) on Tue, Sep 30, 97
Last update made Thu Oct 2 11:22:11 EDT 1997.
Back to Table of Contents
EMAIL: fgarvan@ufl.edu fgarvan@ufl.edu