Homework #8

All problems MUST be in a SINGLE *.m file and be in separate blocks using '%% Problem X'. Otherwise you will not receive credit. You may need additional files for class definitions or functions. See class webpage for naming convention.

Contents

Problem 1

Create a 100 x 100 matrix of random numbers drawn from a uniform distribution on the interval 0 to 1. Find the mean value of all the numbers in the matrix.

Problem 2

arctan(1)=pi/4. One way to numerically calculate pi is using the series expansion of arctan.

http://en.wikipedia.org/wiki/Inverse_trigonometric_functions#Infinite_series

% Use a 'while' loop and the Euler version of the series expansion to find
% how many terms in the expansion you need to
% converge to pi within machine precision. Stop when term to be added is
% less that 'eps(pi)'.  See 'help eps'

Problem 3

Generate a 3D random walk with 10000 steps. Plot the trajectory in 3D

Problem 4

Use 'fminsearch' to find the minimum of the Rosenbrock function when a=1, b=100.

http://en.wikipedia.org/wiki/Rosenbrock_function

Problem 5

Learn how the 'continue' and 'break' functions work and show a short demonstration.

Problem 6

Create a structure with elements 'a' and 'b'. Show how to add these elements together.

Problem 7

Make a function called XX_myHist.m that replicates the basic functionality of MATLAB's 'hist' function. Use 'bar' to make the bar plots. Test your function using a random vector and compare to 'hist'. Use all of your own logic and low-level functions.

Problem 8

Learn how 'waitbar' works and give a simple demonstration.