Lab01, CISC105, Fall 2007
Goals
By the time you complete this lab, you should be able to:
- Log on to a Sun Ray terminal
- Start up both MATLAB and a web browser (Firefox)
- Type in basic commands into MATLAB and see their effect
- Save a sequence of MATLAB commands into a file (a so-called "dot-M"
file)
- Run an existing .m file
- Use the diary command to save your work into a file you can submit for
grading
- Submit your saved work for grading using "MyCourses" (also known as
WebCT).
You might not get through all of this today, and if so
that's ok—you'll have some more time in next week's lab to finish this up.
But get as much done as you can this week, because there
will be additional stuff to do next week.
Step-by-Step Instructions
Step 1: Logging on to the Sun Ray
First,
find a Sun Ray
To use MATLAB on Strauss, the easiest path is to find a Sun Ray machine
on campus.
- It is possible to use MATLAB on strauss from a PC running an X
Server such as eXceed, or Cygwin-X, this is not the easiest path.
- Ditto for accessing MATLAB on strauss from a Mac running OS X---it
is possible, but not the easiest way to get started.
Start on the Sun Rays, get used to MATLAB, and then we might help you
figure out how to do this from your PC or Mac later on.
Where can I find a Sun Ray?
There are several spots where these can be found:
How will I know if I found a Sun Ray?
If you find one, the main screen should look something like this:
- You might also find a screen like the one below. This screen means
someone is working on this machine, and locked it momentarily, perhaps
to pick up a printout, or use the restroom. He/she should be back within
10-15 minutes. If she/he is NOT back within 10-15 minutes, then he/she
is being quite rude---in this case, if there is no other machine
available, you might consider resetting the machine. This, of course,
could also be seen as rude, so think twice, and take a deep breath
before you do it. It might be best to check with a consultant,
instructor, or TA first if one is available---they might be willing to
take the heat for you in case the culprit returns.
- The way to reset a locked session it to type "CTRL-ALT-BACKSPACE"
twice. Note: this may cause the person to lose his/her work if
she/he didn't save it, so be prepared for an unhappy camper. It is also
possible the person just forgot to logout.
Ok, I found a Sun Ray. What next?
Next, you need to login. There is already a web page that describes how
to do this in detail, which can be found at:
http://www.udel.edu/topics/os/unix/sunray/aboutTerminal.html
The following instructions are summarized from that page.
Using Sun Rays Terminals to Connect to Computers

As a Sun Ray user, you start a Sun Ray session by
logging on to a Sun Ray server (e.g. schubert,
vivaldi, haydn).
From the Sun Ray desktop, you can
- run software such as MATLAB on remote hosts such
as strauss, as well as
- local software applications such as Firefox that
you run on the local host (the Sun Ray server itself).
Your home directory (which contains all the files you save to the
hard drive) is shared between strauss and the Sun Ray servers.
The Sun Ray server's software allows you to
- suspend your activity on the terminal at which you're sitting;
- free the Sun Ray for others to use; and later
- continue where you left off at any Sun Ray terminal.
This is possible because all of your session information is
maintained on the Sun Ray server.
There is a load-balanced cluster of five Sun Ray servers, named
Haydn, Schubert, Vivaldi, Verdi, and Debussy, not just one server. Each
time you log on at a Sun Ray terminal, you might get a different Sun Ray
server. The servers all act identically and share the information they
need to identify you and your suspended Sun Ray session.
A Sun Ray smart card is a credit-card-sized identification card used
for logging in at a Sun Ray terminal.
You don't need to use a smart card to log in, but the card
offers two key advantages:
- The login process is much faster; and
- you can suspend and restart your session at different Sun Rays.
Sun Ray smart cards are sold at the University Bookstore for around
$6 to $7.
If you use a card, insert it before you start to log in
Insert it into the Sun Ray's card reader, as shown in the picture
above. When the card is correctly inserted, the green LED light just
above the card slot will illuminate.
Write your e-mail address on your card so you can be contacted by
someone who may find your card. Private information, such as your
password, is not stored on the card's smart chip. (You will
always need your card and your password to continue the suspended
session associated with the card.) The first time you insert your card,
your identifying information and the internal identification code of the
smart card's chip will be stored in a central database.
Starting a Sun Ray
Terminal Session
- Find a Sun Ray terminal with the standard login panel displayed
on the screen.
- Here is a standard login with the "Welcome to haydn"
message.

The welcome message will refer to one of the Sun Ray servers
(haydn, schubert, vivaldi, verdi or debussy).
- You might see an unoccupied Sun Ray terminal without a
standard login panel. It could have a password-protected
screen-saver such as the panel below.

This occurs when the terminal's previous user leaves the Sun
Ray in a locked state, expecting to return to it shortly. If the
user doesn't return within a reasonable time, you may follow the
reset instructions below to allow you to use the Sun Ray
terminal.
Reset Instructions
- If a smart card is in the Sun Ray, remove the
card and give it to the site assistant. If the previous
user retrieves his smart card, he will be able to use it
to restart his session later on any Sun Ray.
- If a smart card is not there, depress and
hold the "Control" and "Alt" keys, and press the Back
Space key twice in quick succession. The terminal should
become reset within 15 seconds.
- If you have a Smart Card, insert it before you log in. You must
do this if you plan to suspend and resume this session.
- After the screen resets itself, you should see a standard
login screen as above.
- If you see a locked screen panel with your user name, then
you can resume this suspended session by typing your user name
and pressing
Return
- Note: Instead of
Return , the key might be
labeled as the Enter key.
- If you see some other user name in the locked-screen panel,
then you are using the wrong card. You can not resume the
session attached to this card. Pull the incorrect card out and
then insert your card.
- Type your user name in the box provided on the standard login
panel, and then press
Return or click the button
labeled OK .
- Your username is your just the username
part of your UD email address, i.e. just
jdoe,
not
jdoe@udel.edu
- You will get a Welcome message with your user name. If you
see the "GNOME 2.0 Desktop" phrase under the your welcome banner
in the login panel, type your password and press
Return .
Note: Your password will not appear as you type, and there are
no little stars *** to guide you. Just type, and hope everything
is working. :-)

- If you do not see the "GNOME 2.0 Desktop" phrase
- Select
Options > Session > GNOME 2.0 from
the pull-down menu.
- Then, type your password and press
Return .
- Once logged in, you will be working in the
GNOME Desktop Environment.
Ending a Sun Ray Terminal Session
You can suspend or you can terminate your
session and its associated current jobs.
- Suspending a session allows you to go
to any Sun Ray later, and continue right where you left off.
(Applications that are running on a remote server, such as Strauss,
will continue to run even when your Sun Ray session is suspended.)
To suspend a session, you must be using a Sun Ray
smart card.
- Terminating a session will close all
the open windows and stop all processing.
- If You Are Using a Smart Card
-
- To suspend a session,
remove the card from the smart card reader. Do not select
the Logout menu item.
- To terminate
a session, select the
Applications > Logout
menu item. Do not select the "Save Current Setup" choice
in the logout dialog box. Remove your smart card after the
logout process is done.
- If You Are Not Using a Smart Card
-
- To terminate
a session, select the
Applications > Logout
menu item. Do not select the "Save Current Setup" choice
in the logout dialog box.
Resuming a Sun Ray Terminal Session
To resume a session, you should use the same card
you pulled to suspend the session. Insert this card in any Sun
Ray terminal on the UD campus that is
displaying the standard login panel. After a screen reset you should see
the lock-screen panel with your user name displayed in the box labeled
User:
-
You must type your password and press Return to resume
your suspended session and continue your work.
Need more help?
Please consult the Troubleshooting section of
GNOME Desktop for UD Sun Ray Terminals at the following link:
http://www.udel.edu/topics/os/unix/sunray/aboutGnome.html#troubleshooting
Ok, I'm logged in. What next?
OOk, you should now see the Gnome Desktop, which looks something like the
image below (I'm showing only the upper left hand corner to save space):
We are now ready to move to step two, which is starting up MATLAB and a
web browser
Step 2: Start up both MATLAB and a web browser
(Firefox)
So, from Step 1, you should be logged into a Sun Ray, and looking at the
Gnome Desktop.
Next, use the mouse to select the Applications Menu, and then the
option Other, and finally MATLAB,, as shown here:
Next, you'll see the MATLAB splash screen (pictured below.) This should
stay on the screen for a few seconds, and then be replaced by the MATLAB
desktop, pictured after the splash screen.
MMATLAB splash screen
MATLAB desktop
What about starting up the web browser?
On the applications menu (the same one you used to start up MATLAB) you
should find a menu item called "Internet", and under that, an item called "Web
Browser" (or something like that). Select that option to start up Firefox. At
the bottom of your screen, you'll see tabs that you can click on to move back
and forth between the web browser and the MATLAB window.
Now, if you are working from a printed copy of these
instructions,
find this page in the web browser window.
Enter the address for the course web page:
http://www.udel.edu/CIS/105/haggerty/07F/
Then, find the current semester, and click on
labs, then on
lab01.html.
You should then be looking at a copy of this page in the web browser. If not,
ask your TA for assistance.
Step 3: Type some basic commands into MATLAB and see their effect
The following exercises are designed to get you comfortable with the MATLAB
environment. They are based on material from your
textbook,
MATLAB, by Holly Moore.
Having the textbook with you today, isn't required, but it will
help
Without it, you'll be able to get through this, but you won't learn as much.
I'm going to guide you through a number of steps. In these instructions, I'm
only going to concentrate on telling you
- what to do, and
- how to do it.
What may be missing is why you are doing it, and what you are
supposed to learn from that. That information is in the textbook.
So, get in the habit of bringing your book with you to lab.
If you have the textbook, open to the MATLAB
Environment Chapter
and start reading where it says "MATLAB WINDOWS"
Continue through the section titled "Command History"
You are about to use MATLAB to calculate the area of a circle of radius 2.5.
Try typing this into the command window:
>> area = pi * 2.5 ^ 2
You should get the following result:
area =
19.6350
Now try typing the following:
>> x = 1 + 1/2 + 1/3 + 1/4 + 1/5 + 1/6;
If you put the semicolon (; ) on the end, then MATLAB will print
nothing in response except the symbol >> , which is called the
prompt. The prompt is where you type input into the MATLAB Command Window.
But what you have done is to assign a value to a MATLAB variable
called x. The value of x can be shown by just typing the letter x
by itself on the command line, like this:
>> x
The result should be something like this:
x =
2.4500
In the days and weeks to come, as you read the text and learn more about
MATLAB in lecture, you'll have a lot more things to type in here. For today, it
is enough that you know how to find the MATLAB command window, and what it means
to "type something in and get a response."
Step 4: Save a sequence of MATLAB commands into a file (a so-called "M-file"
file)
A sequence of MATLAB commands can be saved in a so called "M-file". An M-file
is called an "M-file", because it has a name that ends in ".m", such as:
plotResults.m
calculateAnswer.m
labReport.m
- etc...
To create a new .m file, choose "File"/"New"/"M-file". This will open a
window where you can begin to type commands. Be patient—it may take several
seconds for the new window to open!
Into this window, type the following. Where it says "insert your name here",
put your full name. DON'T put your student id number---just your first and last
name is sufficient!
% This M-file calculates the area of a circle and displays the result
% Written by (insert your name here)
radius = 2.5;
area = pi * radius ^ 2;
string = ['The area of the circle is ' num2str(area)];
disp(string);
When you are finished, use the Save As command from the File menu to save
the file with the name lab01.m
The filename is entered at the bottom of the window, as shown in the
illustration below

Step 5: Run an existing .m file
To run an existing .m file, just type the name of the file. For example, try
typing
>> lab01
You should see output like the following:
The area of the circle is 19.635
>>
If so, you are finished with this step! If you have difficulty, then ask your
TA for help.
Step 6: Use the diary command to save your work into a file you
can submit for grading
In the command window, type
>> diary lab01.txt
This turns on a record of what you type in MATLAB. Then type these three
commands:
>> type lab01.m
[a listing lab01.m will appear here]
>> lab01
[the output from lab01 will appear here]
>> diary off
You should now have files in your account called lab01.m and lab01.txt. In
the next step, you will submit these two files for grading by your TA.
Step 7: Submit your saved work for grading using "MyCourses" (also known as
WebCT).
The following web site describes how to log on to MyCourses.
Note that although you can log on to MyCourses (also known as WebCT) from any
web browser, in order to submit the work you do in MATLAB, you need to be on one
of the SunRays on the UD camnpus so that you can get at the files lab01.m and
lab01.txt
Log on to MyCourses (WebCT) and
find CISC105 (if it is not listed, tell your TA, and email your instructor!)
Follow the instructions for
submitting an
Assignment in WebCT (submit this as lab01). You should submit two files:
- lab01.m
- lab01.txt
And you are all finished!
End of lab01 for CISC105, Fall 2007 (50 pts)
This lab was copied and adapted with permission from Phill Conrad
|