MATLAB Project: Getting Started with MATLAB
To learn to create matrices and use various MATLAB commands. Examples here can be
useful for reference later.
MATLAB functions used
from Laydata Toolbox
This can be used as a brief tutorial and as a reference for basic operations. Use MATLAB's
command or see a User’s Guide for more information. Some of the commands discussed here are about linear algebra
topics which will not be formally introduced in your course for several weeks, so even if you go through this project
early, you may want to refer back to it at various times. Write notes and questions to yourself as you work through it.
Start MATLAB by clicking on its icon (or if you have MATLAB 3.5, type
at the DOS
prompt). The MATLAB prompt is a double arrow,
. In this project each line that begins with
is a command
line, and the bold face words following >> are MATLAB commands. Try each of these for yourself: that is, type the
bold face words and then press the key that is labeled "Return" or "Enter," to cause those commands to be executed.
(In the first few sections we will write
to mean press that key, but we will omit this "carriage return" prompt
later.) After you execute each line, study the result to be sure it is what you expect, and take notes. After trying the
examples in each section, do the exercises.
If you do not complete this tutorial in one session, the variables you created will be erased when you exit
MATLAB. See the remark before Section 6 to find out how to get them back quickly the next time you continue work
on this project.
1. Creating matrices, page 1
2. The arrow keys, page 2
command, page 3
command, page 3
5. Accessing particular matrix entries, page 3
6. Pasting blocks together, page 4
7. Some special MATLAB functions for creating matrices:
8. Using the
to create vectors with evenly spaced entries, page 5
9. Using the
to suppress printing, page 5
command, page 5
11. Matrix arithmetic, page 6
12. Creating matrices with random entries, page 7
13. Plotting, page 8
14. Creating your own M-files, page 10
15. Ways to get Laydata Toolbox and ATLAST M-files, page 10
16. Installing M-files into the MATLAB path, page 10
1. Creating matrices.
is a rectangular array, and in linear algebra the entries will usually be numbers.
The most direct way to create a matrix is to type the numbers between square brackets, using a space or comma to
separate different entries and a semicolon or [Enter] to create row breaks. Examples:
>> A = [1 2;3 4;5 -6]
>> B = [1 -2 3
>> x = [4;3;2]