This preview shows pages 1–3. Sign up to view the full content.
MATLAB Project: Getting Started with MATLAB
Name________________________________
Purpose:
To learn to create matrices and use various MATLAB commands. Examples here can be
useful for reference later.
MATLAB functions used
:
[]:;+*^
size
,
help
,
format
,
eye
,
zeros
,
ones
,
diag
,
rand
,
round
,
cos
,
sin
,
plot
,
axis
,
grid
,
hold
,
path
;a
n
d
randomint
and
startdat
from Laydata Toolbox
Introduction.
This can be used as a brief tutorial and as a reference for basic operations. Use MATLAB's
help
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.
Instructions.
Start MATLAB by clicking on its icon (or if you have MATLAB 3.5, type
matlab
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
[Enter]
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.
Sections:
1. Creating matrices, page 1
2. The arrow keys, page 2
3. The
size
command, page 3
4. The
help
command, page 3
5. Accessing particular matrix entries, page 3
6. Pasting blocks together, page 4
7. Some special MATLAB functions for creating matrices:
eye
,
zeros
,
ones
,
diag
,page4
8. Using the
colon
to create vectors with evenly spaced entries, page 5
9. Using the
semicolon
to suppress printing, page 5
10. The
format
command, page 5
11. Matrix arithmetic, page 6
12. Creating matrices with random entries, page 7
13. Plotting, page 8
14. Creating your own Mfiles, page 10
15. Ways to get Laydata Toolbox and ATLAST Mfiles, page 10
16. Installing Mfiles into the MATLAB path, page 10
1. Creating matrices.
A
matrix
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]
[Enter]
A=
12
34
56
>> B = [1 2 3
[Enter]
456]
[Enter]
B=
1
23
45

6
>> x = [4;3;2]
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentPage 2 of 11
MATLAB Project: Getting Started with MATLAB
This is the end of the preview. Sign up
to
access the rest of the document.
 Fall '08
 Lewis
 Linear Algebra, Algebra, matlab, Matrices

Click to edit the document details