By the time you complete this lab, you should be able to:
.m
filediary
command to save your work into a file you can submit for grading 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.
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.
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.
Two main places:
If you find one, the main screen should look something like this:
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.
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.
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:
Sun Ray smart cards are sold at the University Bookstore for around $6 to $7.
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.
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.
Return
Return
, the key might be labeled as the Enter
key.Return
or click the
button labeled OK
.
jsmith
, not jsmith@udel.edu
Return
.
Options > Session > GNOME 2.0
from the
pull-down menu.Return
.You can suspend or you can terminate your session and its associated current jobs.
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. Applications
>
Logout
menu item.
Do not
select the "Save Current Setup" choice in the logout
dialog box. 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.
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, 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
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.
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.
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.
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."
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
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
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.
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.
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:
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.
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.