University of Alaska Fairbanks
Geophysical Institute

Beyond the Mouse - The geoscientist's computational chest.

2. Fundamental Programming Principles

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

Brief Intro on how programming works, what variables and data types are, and control flow including a little logic.

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 As said in the lecture, read the documentation on cell arrays and structs in Matlab:
> doc cell
> doc struct
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). 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 Soon.

ronni <at> gi <dot> alaska <dot> edu | last changed: March 30, 2009