University of Alaska Fairbanks
Geophysical Institute

Beyond the Mouse - The geoscientist's computational chest.

2. Fundamental Programming Principles I -- Variables and Data Types

"Programming is legitimate and necessary academic endeavor."
Donald E. Knuth

Brief introduction on how programming works, what variables and data types are, how to think about them and how you could/should use them.

Lecture

fundamental programming principles (pdf)

Examples

For this lecture examples are the flowcharts given in the pdf. The few sources are available as tar.gz or zip archive.

Exercises:

2.0 a) Get Matlab set up (check Geology Dept. machines // your work station / labtop for installation). If you don't have access, ask at the Computer Ressources Center. The CRC is located in suite 227 of the Elvey Building. If you are in the Geology Dept. Bill Witte should be able to help you.
2.0 b) As said in the lecture, review the introductory part on cell arrays and structs in Matlab. Jeff will cover that again next week, but you should be mildly familiar with the concepts as introduced in this lecture. Maybe read the Matlab documentation on that:
> doc cell
> doc struct

online at: struct, cell

2.0 c) Understand the "text editor story" by scanning through: http://en.wikipedia.org/wiki/Text_editor.

2.1 What datatype would be most appropriate for the following values? Think about how you would use the data, most probably you will iterate over some of it, and how you could access it most conveniently (you can use Matlab datatypes):
a)1, 2.3, true, 'c', 'hi there!'
b)Open a terminal window, type

> less /etc/passwd

(type 'q' to exit). Or get an example file here: passwd.txt and open it in a Text Editor.

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. We will learn about that later.

2.2 This task comes with the comments on the first assignment. It will be more specific for each student's project.

ronni <at> gi <dot> alaska <dot> edu | last changed: September 17, 2009