function newtdrive%we pass our values for qnewt here
%
0ewtdrive.m
%
%Using a combination of polyval and a program created to take the
0erivative, mypolyder, to find the Newton's basins and wasteland using
%Newton's step. Also using the matlab find functi
4
Solving One Complex Equation via Newtons Method
Matlab Concepts: String manipulation via strcat and strrep, working with polynomials via
polyval and roots, using find, pointwise operations, ecient coding by eliminating loops
Newtons method extends easil
1
Iterations, Matrices, and Fractals
Matlab Concepts: for loops, vectors, matrices, programs, basic plotting
Isolated computations can often be done using pencil and paper or a calculator. A computer
program such as Matlab becomes truly useful when one mu
Representing Numbers in Matlab
Real numbers (R) are represented by a oatingpoint number system on digital computers. The idea is similar to scientic notation, in which a very small or very large number
is represented by a number of moderate size multipli
3
Finding the Roots of a Real Equation
Matlab Concepts: Coding mathematical algorithms
Matlab provides many means with which to solve equations, including its polynomial root
nder, roots, and its symbolic solver, solve. We will write our own rootnder usi
5
Optimization
Matlab Tools: Optimization solvers fminunc and fmincon, nested functions, inline functions,
3D plots using surf, bar graphs
Optimization is a branch of mathematics in which one determines the variables corresponding
to the minimum or maximu
Table of Contents
.
Part 1: Bisection graph .
Part 2: Bisection vs. Newton graph .
Bisection Method .
Newton's Method .
Evaluation of Function .
Evaluation of Function's Derivative .
1
1
2
3
4
4
4
function cooldrive
%
%
%Using two different methods, Bisec
2
Sequences and Series
Matlab Concepts: for/while loops, functions, subfunctions, logarithmic plots, 3D plots
This week we will study how Matlab can be used as a tool to numerically study the convergence
of sequences and series. Such numerical studies can
6
Gaussian Elimination
Matlab Concepts: Coding algorithms, constructing linear systems
Matlab has a vast array of tools for linear algebra tasks. We have already seen how Matlab
eciently computes multiple equations at once through the matrixvector produc
8
Boolean Gene Networks
Matlab Concepts: Boolean logic, binary expansions, bioinformatics toolbox, cell/structure arrays
We have now seen two examples of discrete dynamical systems, or systems for which we
move from point to point at prescribed times (cor
%
% Kathryn Hedrick, EN.500.200, F2014, Lab Example
%
% labex.m
% Generate the pattern containing the product of the first n numbers
%
% 2. Plot each number in the pattern
figure
p = 1;
plot(1,p,'.r','markersize',16) % Plot 1st number in pattern
hold on
f
11
Recursive Functions
Matlab Concepts: Recursive functions
We are now experts in performing iterative computations using for and while loops. This
week well explore a second method: the use of a recursive function, or a function that calls
itself. For ex
10
Deterministic Chemical Kinetics
Matlab Concepts: symbolic toolbox, analytical and numerical solutions to ODEs, global vs. local
variables
The stochastic view is a barehanded means of following the dynamics of individual molecules.
For large reacting s
Project 6: Gaussian Elimination
10/21/2014
1.
The aim of this project was to solve for the coefficients of a trigonometric equation
using curve fitting and Gaussian elimination to solve a linear system. This was done through
creating a Gaussian eliminatio
Project 12: Evolutionary Game Theory
12/19/14
1.
The aim of this project was to run experiments on Evolutionary Games and Spatial
Chaos on an MbyN board. A prisoners dilemma situation was conducted with certain point
values that refer to different outco
Example Coding Project for Lab, 82914
1. Create a program named labex.m by typing edit labex.m.
2. Generate the pattern
n
pn =
i
i=1
using a for loop. Plot the points, cfw_(n, pn )6 as red dots. (Type help plot.)
n=1
3. Use a for loop to store the rst s
function mygilldrive
%Clara Molineros
%
%mygilldrive.m
%
%The goal of this project was to simulate stochastic dynamical systems,
%using cell arrays, cumsum, and interp1.
T=100;0uration (in sec) of the simulation
tinc=.1; %increment(sec) btwn interpl time
Table of Contents
.
Part 1: Fibonacci sequence .
Part 2: Geometric series .
Subfunction fib .
Subfunction geo .
function fib_geo
%
% HW2
%
% fib_geo.m
%
%This code utilizes subfunctions, for loops, and while loops
%to explore the convergence of a famous s
function hopfield
figure
paintings=cfw_'scream.jpg','gothic.jpg','frida.jpg','pearl.jpg';
imgscfw_4=[];
ibwcfw_4=[];ets up slots for values
for i=1:4
imgscfw_i=imread(paintingscfw_i);%cfw_ are for accessing arrays
ibwcfw_i=real(im2bw(imgscfw_i);%real() ma
Quiz 2
All answers should be written in Matlab syntax, as you would write the commands in the
Matlab command window or editor.
1. Suppose the vector s is constructed through the following code:
s = ones(1,10); % sets a vector of all ones, 1 row, 10 column
%
%m HW 1
%
%
%
% This code utilizes linear transformations and probablility and ifelse
% clauses to manipulate the shape of the oldschool fractalfern and
% form it into a different fractal fern.
%
z = [0; 0]; %initializing the variable z
for j = 1:10e3
function sudokudrive
%
udokudrive.m
%
%The goal of this project was to create a Sudoku solver using
matlab's%recursive fuctions.
load puzzle.mat
disp('Unsolved puzzle.mat')how unsovled
showPuzzle(M)
[M fin] = solver(M);
disp('Solved puzzle.mat')how solved
function reacdrive
%
%reacdrive.m
%
% This assignment used the symbolic toolbox, analytical and numerical
% solutions to ODE's, and global variables to model deterministic
chemical% kinetics.
close all
T=100;0uration (in sec) of the simulation
tinc=.1; %i
function optidrive
%
%optidrive.m
%
%Used nested functions, inline functions,linspace, and fmincon and fminunc
%to solve optimization problems, one constrained and one unconstrained.
Pt I: Optimal Lifeguard Strategy
function f= lfgrd(y1)
f = (sqrt(30^2 +
"'l'  u.qrir _
"F .
IIu .I._r. .1. _
_.
1.! allh
I
i
r
I!
1"
III
 r.
l.
" 11. _
I ' 1. 4.?
l
Ii
I
'.'
d 1.' .
' n. . r 'i i. p a
. Uhlr w._H_.1F_Hur #_.1d_H_dr
Wu M'H'Wiw :  *arinl'IH «
I i'
y. u . I
i

. 1.
II
thqqua. m .
Quiz 1
4/14
All answers should be written in Matlab syntax, as you would write the commands in the
Matlab command window.
1. Write a for loop to compute the sum of the rst 50 odd numbers. In other words, compute
the sum of the set cfw_1, 3, 5, . . . , 99.