The purpose of this exercise is to introduce you to Matlab which is the main programming language you will be using in this course. Matlab is an interactive language for technical computing based on array manipulation. It has many useful built in functions, and can be used to write programs and interface to various systems.
There is substantial online information about Matlab. It
would be worth spending some time outside the class exploring it:
http://www.mathworks.com/support/
You can use the software outside the class times, on most Dice machines. However, note that there are a limited number of licenses for Matlab, meaning only a limited number of people can use them at the same time. So please: don't use them during other lab times; don't use them if you just want to browse the helpfiles, but read the online manuals instead; and don't stay connected to them when you have stopped using them.
To start Matlab: with the graphical interface, from the shell type matlab &.
NOTE: If you receive a warning that the
correct command should be matlab14 then you may need to tell the
computer where in its filesystem it can find the
matlab executable.
In the terminal window type
export PATH=$PATH:/opt/matlab-R2014a/bin/.
You should now be able to run matlab using
matlab &.
You should see a graphic appear for a moment on your screen, and the
following will appear in the command window:
>>
You can then type commands at the prompt. We suggest you run:
>>edit intro.m
to first see the code that is going to be run, and then input:
>> intro
to see what it does. Please go through and understand each line.
For a quick explanation of other basic features. If you want to go a bit
further with this after the session, try:
>>
helpdesk
and
work through some of the material under 'Getting started'.
This will capture 5 frames, but will then hang. Use CTRL-C to kill the process. The captured frames will be in the files 0000000X.jpg, where X=1/2/3/4/5. Check these (using e.g. xv or gimp) and use one of the good images.
Once you have captured an image, try:
xv
<filename.extension>
(using whatever was the name and format of your captured
image, e.g. xv foobar.ppm).
This is an image viewing and conversion program. You can right click on
the image to get the menu 'xv controls'. Try saving the image in pgm
ascii
format: Set 'Format:' to PBM/PGM/...*ascii) ,
set 'Colors:' to Greyscale
and set 'filename extension' to pgm. A new
file appears in the xv controls
windows - double click on this filename to see the greyscale
image.
In the shell, if you now type :
more
foobar.pgm
You can see the file format, looking something like this:
P2
# CREATOR: XV
Version 3.10a Rev: 12/29/94 (PNG patch 1.2)
320 240
255
41 41 41 40
40 39 40 40 39 39 38 38 38 38 38 38 37 37 37 36 36 35
etc.
Line 1 = file type ('man pgm' tells you all about this)
Line 2 = Image comment tag
Line 3 = Width and Height (X * Y)
Line 4 = maximum grey value; here 8 bit color 255 = white, 0 = black
Line 5 onwards = actual pixel values!!
This will capture 5 frames, but will then hang.
The captured frames will be in the files 0000000X.jpg, where X=1/2/3/4/5.
Check these (using e.g. xv or gimp) and use one of the good images (usually image 4 or 5 is good).