MAE20 Introduction to Programming and Numerical Methods


Students should leave the course feeling confident in creating programs of moderate length. They should recognize that they can learn another programming language without great difficulty. Numerical methods, listed below, were covered and and implemented.


  1. Introduction to Matlab environment. Matlab as a calculator. Simple plotting.

  2. Variable types. matrices and vectors. Character strings. Arithmetic operations. Built-in functions.

  3. Finite difference method.

  4. Relational and logical operators. IF construct. Loops.

  5. Least squares curve-fitting.

  6. User-defined functions.

  7. Numerical integration.

  8. Root-finding by Newton’s method.

  9. File input and output. Formatted output and input.


The largest impact that I had in this course was developing fun and “real world” projects using simple computer graphic principles such as rotation, translation, and scaling, but still relating these to applications that they use often in engineering. These applications span CNC machining to designing a scrolling LED clock and simulating it. All the projects are described below. For more detail on each project click on “handout”. In addition, I ask the students to be creative and add an undefined portion to the project. One of my favorite creative programs was a “pong” game that you could actuatlly play (see below)!

LED CLOCK SIMULATION (handout) - Spring 2006

This project came from my interest in building a scrolling LED clock:

(14MB file, Video is slow to load)

OPTIMIZATION (handout) - Fall 2005

After taking Linear Programming(LP) with Prof. Lieven Vandenberghe, I wanted to show students what kind of real world problems can be solved by advanced algorithms such as the Simplex Method. This project required the students to solve 2D LP problems and visualize it as shown in the figure. Here is an example LP (with 2 variables):

A Farmer’s diet plan for his chickens from a fun book about optimization called “When Least is Best” by Paul Nahin:

“Imagine that, to be healthy and grow into a fine, fat chicken dinner, a chicken needs to consume a minimum weekly amount of three different nutrients each (called A, B, C). Let’s futher assume, to be specific, that the minimal amounts are (in some unit system) 60, 84, and 72, ounces respectively. The local feed store stocks two brands of chicken feed, markedly different from each other. One is cheap because it’s low on nutrients per ounces, and the other is expensive because it’s high on nutrients per ounces.” See table showning amount of nutrients of A,B, and C in each Feed:

Feed A B C Cost
(cents per ounce)
#1 3 7 3 10
#2 2 2 6 4

It turnes out that the farmer would need 24 ounces of the expensive feed, at a cost of $2.40 per week, for the chickens to have enough of each nutrient. Or the farmer would need 42 ounces of the cheap feed, at a cost of $1.68 per week. So if the farmer, wanting to minimize cost, would choose the cheap feed at $1.68 per week. So is that the least amount of money that the farmer could spend to feed his chickens? The answer is NO. What if we buy a certain amount of the cheap feed and a certain amount of the expensive feed (a mixed stategy) could we get enough nutrients at a cheaper cost? This problem can be formulated as an LP and the solution is 6 ounces of the expensive feed plus 21 ounces of the cheap at a cost of $1.44 a week!!! Optimization is so cool!



The purpose of this project was to write a simple SOLIDWORKS type (only 2D) program to take a 2D object and use mouse feedback to rotate (see figure), translate, and scale the object.


LASER TARGETING (handout) - Winter 2005

This project was suggested by my friend Jason Marden related to an aerospace problem.


CNC CODE (handout) - Winter 2006 and Fall 2004

This project uses CNC milling machine G-Code as the motivation. The students were to write function that two points (P_1,P_2) and a radius (R) and plot the arc using matlab plot function. This entails knowledge of Transformation and rotation matrices along with matlab programming.

Student Extras

Every project had an undirected artistic portion where the students were free to come up with a cool program. Here are a few:

This is such a great program! You can play “Pong” on matlab!


Here is another fun program that animates a fish bowl scene where the fish is moving around the screen and the water changes level.