Lab01, CISC106, Fall 2007

Goals

By the time you complete this lab, you should be able to:

  1. Log on to a Sun Ray terminal
  2. Start up both MATLAB and a web browser (Firefox)
  3. Type in basic commands into MATLAB and see their effect
  4. Save a sequence of MATLAB commands into a file (a so-called "dot-M" file)
  5. Run an existing .m file
  6. Use the diary command to save your work into a file you can submit for grading
  7. 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 many students last year were able to finish within one 50-minute lab period.

In any case, 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

The most up-to-date instructions for doing this are available at the following link

https://www.phillconrad.org/cisc106/Wiki.jsp?page=CISC106_Accessing_MATLAB_on_strauss

Here is a "snapshot" of those instructions, provided for your convenience.

First, find a Sun Ray

To use MATLAB on Strauss, the easiest path is to find a Sun Ray machine on campus.

Start on the Sun Rays, get used to MATLAB. Later, we'll show you how to use MATLAB from a PC or Mac.

Where can I find a Sun Ray?

Two main places:

  1. Willard Hall 009B
    • (just inside the door to Willard Hall that faces Main Street, to the left as you enter, at the bottom of the ramp)
  2. The Basement of Smith

How will I know if I found a Sun Ray?

If you find one, the main screen should look something like this:

http://www.udel.edu/CIS/images/SunRay.WelcomeToHaydn.png

http://www.udel.edu/CIS/images/SunRay.XScreensaver.png

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

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

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.

Sun Ray Smart Cards

SunRay smart card

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:

  1. The login process is much faster; and
  2. 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

  1. 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.

      Welcome to Haydn

      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.

      Lock screen image

      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.
  2. 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.
  3. 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 jsmith, not jsmith@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. :-)

      Welcome user name

    • 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.
  4. 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:

Lock screen image

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?

Ok, 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):

http://www.udel.edu/CIS/images/SunRayDesktopUpperLeftCorner.png

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:

http://www.udel.edu/CIS/images/SunRayDesktop.Application.Options.Matlab.selected.png

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.

MATLAB splash screen

http://www.udel.edu/CIS/images/matlab/matlab.R2006a.splash.screen.png

MATLAB desktop

http://www.udel.edu/CIS/images/matlab/matlab.desktop.png

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/106/pconrad

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. For now, we'll do all our work in the Command Window part of the MATLAB environment.

First, let's calculate the value of 5 squared. Type it in and hit "return" (or "enter").

>> 5^2

You should get the following result:

 ans = 
25

Now, use MATLAB calculate the area of a circle of radius 6. Try typing this into the command window:

>> area = pi * 6^2

You should get the following result:


area =

  113.0973

>> 

Now try typing the following:

>> x = cos(pi);

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 =

    -1

>> 

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:

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!

% lab01.m  by (insert your name here)
% Calculate the area of a circle and display the result

radius = 6;
area = pi * 6 ^ 2;
fprintf('The area of the circle is %f\n',area);

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 113.097336
>>

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 campus so that you can get at the files lab01.m and lab01.txt

Log on to MyCourses (WebCT) and find CISC106 (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:

  1. lab01.m
  2. lab01.txt

And you are all finished with lab01. Now you can begin your study of MATLAB in detail, as explained below, by reading Chapter 1, and then working through Chapter 2.

Next steps

So, your next steps is to read through Chapter 1 and Chapter 2 in your Holly Moore text, and most importantly, to work through the material in Chapter 2 while actually sitting at a computer with MATLAB in front of you. Chapter 1 can be read without a computer around, but Chapter 2 is designed to be read with MATLAB there.

You should also read Section 7.2, titled "Output Operations". This section describes two ways to get output in MATLAB, namely disp and fprintf. These are very useful, so we are going to cover them earlier than the sequence indicated in the book. Don't worry about reading this section out of order—section 7.2 doesn't contain any material that isn't already covered by the end of Chapter 2.

For now, you'll probably want to use a SunRay to access MATLAB. SunRay terminals are found in Willard 009B, but that room is typically in use for various computer labs during the week. You can also find SunRay terminals in the basement of Smith Hall. In lecture, we'll talk about you you can also access MATLAB on "strauss.udel.edu" from any PC or Mac with Internet access. There will still be some features of MATLAB that you'll only be able to do on a SunRay, but most features you'll be able to do from anywhere.

End of lab01 for CISC106, Fall 2007 (50 pts)