Beyond the Mouse LAB 1: Thinking Programs
August 29, 31
Instructor: Jeff Freymueller
x7286 Elvey 413B jfreymueller@alaska.eduTA: Shanshan Li
Last Updated: August 27, 2017
Due: Tuesday Sep 5, before class
Exercise 0: Passwords
You all should be able to log in to the computers in the lab using your UAlaska username and password. If not, then talk to Shanshan Li immediately and he will check on it.
Exercise I: Drawing flow charts
In class last week I mentioned that students taking 636 will need to do a project by the end of the semester. For this lab you will pick some project (it might not be your final choice, this is just an exercise, so do not spend a long time trying to come up with your ideal project, just pick something that seems appealing). Try to think ''big picture'': identify manageable sub-units and link them together in a meaningful way. Visualize the result in the form of a flow chart. We recommend hand drawing this as that's faster, things change a lot and it doesn't need to be pretty. Just deliver something that's legible and easy to follow (here are pre-defined flow chart symbols, give definitions for other symbols)
If you did not figure out a project yet, DON'T PANIC!. Try to create a flow chart for the process of writing and publishing a scientific paper. If you really don't know the process, then create a flow chart for how you think it works, or pick a similar process that you understand well. You can find inspiration on the web:
- wikipedia, academic publishing: Find the important sections
- Although intended for Biologists, this strategy for writing up research which is part of a Scientific Writing Guide might help.
- if you don't like the links given here, use a search engine of your choice and get your own inspiration
If you've already written and published a paper you will have an easier time, I suppose. You're welcome to give more details. If some branches of your flowchart explode in great detail, consider to lump these things together. Put them on a separate little flow chart and refer to this from the main chart by including a descriptive name there and on the little chart.
Exercise II: Playing with Code -- Learn to swim in the open waters.
Here, we do not care a bit about your programming experience. We want you to familiarize yourself with the MATLAB environment and get you to start playing around. During this process you will hopefully understand the setup of the environment and get a feeling for how MATLAB tries to help you in moments of distress (Hint: Read the red output!).
Hint: If you want to learn more about the MATLAB commands, type doc COMMAND
or help COMMAND
in the command window.
We want you to document some of your experiences in a textfile. Open notepad; save the file as
deepwater_(yourname).txt
and send it to sli11 <at> alaska <dot> edu
.
Replace ''(yourname)'' with your name. For reasons that will be more clear later in the
semester, I want you to get in the habit of not using spaces in file names. Use underscores
instead.
- Download the examples to your personal space. (You should create a meaningful directory structure along the way.)
- Unpack the examples. You should find the following files:
eat.m, getUp.m, haveLife.m, make_my_day.m, screw2d.m, screw2d_bad.m, sleep.m, walk.m, work.m
We will not care too much about thescrew*
files. - Start MATLAB
cd
to the directory that contains the example files (we'll explain that)- type:
edit make_my_day.m
; an Editor Window opens - you will now change the file. - Suggestions:
- change the order of the lines
- delete stuff / add stuff / add '
%
' in places - change the parameters (stuff in parenthesis and single quotes)
- REQUESTED: change
eat
tofeed_me
- Re-run the script after every change, document the change, and the respective result
- Go to the MATLAB prompt and type:
edit eat.m
, Save the file asfeed_me.m
, also change the name of the function tofeed_me
(Notice the orange box go away), run the script. What happens? - Now change
feed_me.m
- Suggestions:
- change the number in the
pause
call. - change the string inside the
fprintf
call. - remove the first
%s
- What happens in the output? - remove the
mfilename
- See a connection?
- change the number in the
- Look at some of the other files and play with them. By now you should be getting the hang of it.
Dr. Jeffrey T. Freymueller
Professor of Geophysics
Geophysical Institute
University of Alaska, Fairbanks
Fairbanks, AK 99775-7320