Beyond the Mouse Lecture 2: Fundamentals, Variables
September 5
Instructor: Jeff Freymueller
x7286 Elvey 413B jfreymueller@alaska.eduTA: Shanshan Li
Last Updated: August 27, 2017
Reading
You should have already read Chapter 2 through 2.6, and Chapter 6.1 through 6.3.
Lecture
LAB 02
Examples
I give a few simple Matlab scripts and a Shell script as examples for how arrays can be used. The sources are available as tar.gz or zip archive.
Exercises (Due Thursday Sep 7, as these are short):
Exercise 1: Text Editors
Understand the "text editor story" by scanning through: http://en.wikipedia.org/wiki/Text_editor. In particular, make sure you understand the difference between a word processor program like Word, and a plain text editor like Notepad. This may seem silly, but it will be one of your most important tools to choose, especially once you're leaving the MATLAB world. A poor choice in that department can make your work less enjoyable. There are many choices! Your assignment is to try out two or three of them. Tell us what you tried, which one(s) you like, and why.
Exercise 2: Data Types.
What datatype would be most appropriate for the following values? Give the reason behind your answer in complete sentence(s). Think about how you would use the data, and how you could access it most conveniently (you can use Matlab datatypes):a) | 1, 2.3, true, 'c', 'hi there!' |
b) | Open a sample
text file here: passwd.txt and open it
in a Text Editor.
Or, if you are on a Linux machine, open terminal window and type
Think of the ':' as a separator of data fields. How would you store such data? How would you store it if you knew that the first field is a the user name and you wanted to access this field using this information to get all usernames at once? Try to solve the problem on paper without having to worry about reading in the values from the file. Just describe in English how you would extract the usernames from these lines. We will learn later how to write code to do it. |
Dr. Jeffrey T. Freymueller
Professor of Geophysics
Geophysical Institute
University of Alaska, Fairbanks
Fairbanks, AK 99775-7320