Curtis, Ryan ProgrammingWorksheet

Curtis, Ryan ProgrammingWorksheet - CW1 1_ 1/_/11 _ _ 1/ 6...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
CW1 1_____ __________ 1/___/11 _____________________ ____ 1/ 6 Week1 Workshop – Programming 1 Worksheet You should work though this worksheet during workshop today, recording your answers on the separate answer sheet. Be sure to save each of the programs created. 1. What are three of the four types of values in MATLAB? a. b. c. 2. What are the three ways to run a script file? a. b. c. 3. File names and directories a. Open MATLAB b. Download the w1ws.m file from Scholar to your DESKTOP – try to run it by typing w1ws at the command line. What happens? ___________________________________________ c. Move the file to your DOCUMENTS>MATLAB directory – try to run the file by typing w1ws at the command line. What happens? __________________________________________ d. Make a copy of the file (right click, copy), renaming (right click, rename) the copy w1 ws.m – try to
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
run it by typing w1 ws at the command line. What happens? _______________________________________________ e. Open the file w1 ws.m. Try to run it using either Debug>Run or the RUN button. What happens? ______________________________________________________________ 4. Comments a. Delete w1 ws.m. Open w1ws.m. b. Read the comments at the beginning of the file and take note! c. What does this program do: _______________________________________________ Change the comments at the beginning of the file to describe what the file does. A % at the beginning of the line indicates to MATLAB that this line is a comment. (Except in a text string, all characters following a % sign are ignored) Comments at the top of the file are called “Help” comments. After adding the comments save your file and run it. Fix any errors (due to not having the % in the correct place). d. Hover over or click‐on the filename in the CURRENT FOLDER window. What do you notice in the Details Window below the CURRENT FOLDER window? ____________________________ e. Type help w1ws at the command line – what happens? ______________________CW1 1_____‐__________ 1/___/11 _________________________ 2/ 6 f. Add inline comments to explain what each line of the code does. After the end of each line of code
Background image of page 2
add a % followed by the text of your comment. In general you won’t comment EVERY line, but should include comments as needed to help the person looking at your code understand your programming algorithm (what you are doing). Try typing type w1ws at the >> prompt. 5. Variable names a. Change the variable names in the file to more meaningful names, use R for radius, H for height, Area for circular area, Circum for circumference, Volume for Volume, and Surface Area for surface area. Save your file as w1ws.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/02/2011 for the course ENGE 1114 taught by Professor Twknott during the Spring '06 term at Virginia Tech.

Page1 / 11

Curtis, Ryan ProgrammingWorksheet - CW1 1_ 1/_/11 _ _ 1/ 6...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online