for loops. (Basics of for loops. Difference between disp(i) and disp('i'). Example of how scripts remember variables from within the command window, as opposed to functions.)
for loops 2. (The syntax for i = v, where v is a vector. Creating a vector using a for loop.)
Nested for loops. (Make a matrix using nested for loops.)
true and false in Matlab. (true is represented by 1 while false is represented by 0. >, <, >=, <=. Two equals signs for asking true/false, are these two values equal? Logical expressions involving vectors. any, all.)
if statements. (if, elseif, else)
Logic in Matlab. (Not equals with tilde, or, and.)
Counting function. (Write a function to count how many times a number appears in a vector two different ways, one using a for loop and one using a logical vector and the word 'sum'.)
Programming pitfall 1. (A common mistake that students make when writing a true/false function using a for loop. Fixing it by setting a default value at the beginning.)
break and return. (Speeding up the has element function using 'break' or 'return'. Using 'disp' to help test code.)
while loops. (while loops. An example of how scripts can access variables defined in the workspace (unlike functions). Making a vector using a while loop.)
mults 2. (Making a vector similar to what we get using the colon symbol, but instead using a while loop. Special emphasis on the last iteration that occurs when we do a while loop.)
Programming pitfall 2: infinite loop. (When do you use a while loop instead of a for loop? Finding the first prime in a sequence of numbers. isprime. Cancelling an operation when it's in an infinite while loop by holding down control and hitting c.)
while true. (return, isprime. Rewriting our Dirichlet function using `while true', which means to repeat until we break out of the loop.)
More on Dirichlet's theorem. (Writing a function which takes as inputs a, m, n, and as output finds n different primes in the arithmetic progression a, a+m, a+2m, .... We use the syntax v = [v, ???] to generate our vector of primes.)
Unit 2: Lecture videos Unit 2: Due dates and handouts