Due: Fri, September 19, 10:10AM
Worth: 100pts
Here are some website you will find useful throughout CISC106:
The IT help center http://www.udel.edu/help
Login help http://www.udel.edu/help/udelacct.html
SunRay help http://www.udel.edu/topics/os/unix/sunray/aboutTerminal.html
General Unix http://www.udel.edu/help/usingunix.html
Unix File Commands http://www.udel.edu/topics/os/unix/general/filemgmt.html
Disk Quota problems http://www.udel.edu/topics/e-mail/quota/managequota/solutions.html
Additionally, go to the page http://www.udel.edu/network,
log in, and access the option to change your Unix Default Group. Change
your default group to the one that corresponds to CISC106.
On that same page, access the option to change your Unix Default Shell. Change it to /bin/tcsh.
To create a new file go to File > New > M-file. Start every new file with your name and a description of what the file is for:
% filename.m by Your Name
(% makes a line a comment, so MATLAB knows not to execute that line)
% description of filename.m
Demonstrate the following in a diary file (lab02.txt):
In a m-file, you can create functions that take arguments (just like calculus). Make a new m-file and use the following function from the last lab as an example:
function area = circleArea(radius)
area = pi * radius ^ 2 function
- keyword that lets MATLAB know you are writing a function (CAN'T be changed)
area
- the return variable. Can be named anything you want, as long as it refers to the answer of the problem you are trying to solve
circleArea
- function name. The name should be changed to relate to what the function does/solves. (MUST MATCH FILENAME)
radius
- anything in the parenthesis is known as an "argument". These are what you give the function to use.
Now save your file as circleArea.m
*REMEMBER THE FUNCTION NAME NEEDS TO BE THE SAME AS THE FILENAME
Now you can go back to the main MATLAB window and call your function. For example, you can try circleArea(2)
. The usefulness of functions is that you can run the function on any value you pass in.
Make sure your function works by passing in values you know the answer to and making sure it returns what you expect.
Write 2 more functions (in 2 additional m-files) that compute the volume and the surface area of a geometric shape of your choice.
Be sure to choose names that reflect what the function and variables/arguments in the function do.
As you write them, test the functions in the MATLAB command window to make sure they work.
At the end of every lab (unless otherwise stated) you will create a diary file where you:
>> diary lab02.txt
>> type filename.m
>> filename
(repeat for every function)
>> diary off
Submitting to Sakai will put a "time stamp" on your work so we know when you submitted it, but you will also submit a printed copy for grading.
* Note that although you can log on to Sakai 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 to the files
Log onto Sakai (sakai.udel.edu) and find CISC106 (if it is not listed, tell your TA)
Follow the instructions for submitting an assignment in Sakai (help -> assignments -> submitting) and submit this as lab02. You should submit five files:
This lab was adapted from a lab by tharvey.