This course is intended to assist undergraduates with learning the basics of programming in general and programming MATLAB® in particular.
The Basics – In this unit, you will learn how to use the MATLAB® command prompt for performing calculations and creating variables. Exercises include basic operations, and are designed to help you get familiar with the basics of the MATLAB interface. One of MATLAB’s conveniences is its ability to work with lists of numbers. You will have the opportunity to practice constructing and manipulating lists, vectors, and matrices. Since the unit also serves as an introduction to programming, you will receive guidance on defining variables, storing values in variables, and changing the values of variables.
Lecture 1: Using MATLAB for the First Time
Lecture 2: The Command Prompt
Root-Finding – Now that you are familiar with MATLAB® and its basic functionalities, you will learn how to use MATLAB to find the roots of equations, and specifically, nonlinear equations. We will walk through using Newton’s method for this process, and step through multiple iterations of Newton’s method in order to arrive at a final solution.
Lecture 3: Using Files
Lecture 6: Debugging
Basic Plotting – In the previous unit, plotting was introduced with Newton’s method, but it is worthwhile to further explore the capabilities of plotting in MATLAB®. Preliminary exercises will encourage you to discover how to stylize your plots as well as plot multiple functions with the same plot command. To do this, you will be asked to plot different basins of attraction, sets of points that converge to a given root, for Newton’s method.
Lecture 4: Plotting
Vectorization and User-Defined Functions – Another convenience of MATLAB® is its ability to manipulate complex numbers, such that you can take powers and roots of any number. For practice, you will be asked to calculate and plot the basins of attraction for a polynomial in the complex plane. Also in this unit, you will learn how to create a user-defined function in MATLAB. It is important to understand the difference between a script and a function. While a script is a separate piece of code that performs a certain task, it deals with the variables from the caller, and cannot accept input values or provide return values.
Lecture 5: Scripts and Functions
Debugging with MATLAB – At some point you will realize that MATLAB® is not doing what you want it to do. This is normally due to a mistake which is either that you don’t understand how MATLAB works or that you have a typo that MATLAB understands in a way different form what you want it to be. In any case, it is a bug (in your code, as opposed to a bug in MATLAB, which is less likely the culprit), and can normally be traced to one particular line of code that has a typo in it. MATLAB has a “debugger” that helps you locate and correct that line of code.
Fractals and Chaos – A fractal is a geometric figure that can be subdivided into parts that are mathematically similar to the whole. You will be asked to plot the Mandelbrot fractal, and effectively practice constructing while loops, which terminate based on a known and specified condition. You will also learn how to use commands that help you terminate the loop prematurely and otherwise modify the execution of the loop.
Conway Game of Life – This unit challenges you to employ the skills that you have acquired in more complex tasks, as well as in a larger coding project. The project is an implementation of the Conway Game of Life, in which cells in a 2D grid are labeled as either “alive” or “dead.” The game runs according to a defined set of rules, and you will be responsible for calculating each state of the cells, updating the grid, and plotting the grid.
Requirements: Students need to have access to a computer with MATLAB installed. Which version matters little as the course will be using very basic functionality which hardly changes between versions.
Instructor: Yossi Farjoun