Design Patterns: Functions
Lecture Week 9
Design Patterns
We have learnt a number of patterns that we reuse
One way to reuse them is to look them up in our old
code, or notes, and then copy/paste the
^
<
Arithmetic Operators
+
Addition

Subtraction
.*
Multiplication
./
Division
.^
Power
Relational
Relational Operators
<, <=
Less than, Less than or equal to
>, >=
Greater than, Greater than or eq
More Loops and Conditionals
Lecture Week 6
Simple Loop
for i = 1:3
i = 1;
block of code
block of code
i = 2;
end
block of code
The challenge in writing FOR
loops is to figure out a single
block of cod
Motion and Conditionals (If)
Lecture Week 5
MOTION
Put shapes on the figure
Then you can
Make small changes between frames
move them
change them
recolor them.
Time can be 1/20th 1/50th of a second
Fo
Drawing Circles
Lecture Week 3
To Make a Circle
plot(x, y)
plot(y) is the same as
x = 1:length(y)
plot(x, y)
1
0.8
0.6
0.4
0.2
>
>
>
>
>
>
t = 0:360;
x = cosd(t);
y = sind(t);
plot(x, y)
axis equal
ax
Variables and Assignment Statements
Lecture Week 2
Course Team
Arif Zaman
Sohaib Khan
Murtaza Taj
Professor of Computer
Science and
Mathematics
PhD, Stanford, 1988
Research Interests:
Random Number
Introduction
Lecture Week 1
Course Goals
This is a programming course
Goal: To provide scientists and engineers with a
minimal core of basic computational tools
You will learn how to solve computation