MA 490, Winter Quarter, 1999-2000 Homework 1 – due Monday, December 6, 1999 1) Use a script, the subplot command with a 2x2 matrix, and the linspace command to create the x’s (use 128 points in the interval [0; 1]) to create 4 graphs of the cosine function with frequencies k = 2; 5; 8; 12 (i.e. use cos(2¼kx)): 2) Give a simple example (perhaps a loop) to illustrate the commands tic and toc. 3) De…ning a function. The …rst line of a function …le (use help function for more info) should be f unction [x1; x2] = quadeqn(a; b; c) 4) Solve a 3 systems of equations Ax = b (i.e. using the “n”command). a) A is 2 £ 2 and A is non-singular b) A is 3 £ 2 and there is a solution c) A is 3 £ 2 and there is no solution. Note that Matlab still gives a solution - what is it? 5) Use Matlab to sketch the graph of some function z = f (x; y): You might want to look at help on the commands surf, mesh, meshgrid. Or you might want to type peaks and see what happens. You can see the script for peaks by typing “type peaks.m”. 6) Use a script to create a large (100x100) tridiagonal matrix. Then put some non-zero values in the upper right and lower left corners and see what the matrix looks like by using the command spy. 7) Load the clown picture by typing “load clown”. Note that if you now type “who”, you will see the letter X which is the matrix that contains the clown picture. Typing “image X” will open a …gure with the picture in it (to see the size of X; simply type “size(X)”). If the picture appears fuzzy, you may need to type “colormap(map)”. Notice that “map” was also in the who list. This is the color map for the picture. This means that since X(33; 56) = 22; then the (33,56) entry of the picture will have the RGB color scheme given in row 22 of the matrix map (ie look at size(map) or even type map to see its structure). If you want to use gray levels instead of colors, type “colormap(gray)”. Type gray to see the structure of the gray color map. Do you see why you are getting levels of gray? Now that you have done all this, I want you to modify the clown picture by putting some white (or black) rectangles in the picture. That is, give the matrix X a new name and then change blocks of numbers in X: For instance, if you change the pixel X(33; 56) to be 1, then the color of that pixel will be given by the color scheme corresponding to row 1 of map (ie assuming that you changed back from gray to color). To make life a bit easier, you might want to use a command which allows you to look at blocks of a matrix. For example, type X(3:7,4:10) and you see the block of X corresponding to rows 3 -7 and columns 4-10. Furthermore, you can set this block to whatever you want it to be (use help to …nd out what the commands zeros and ones mean). 8) Create a graph which is the sin(10¼x) on [0; 1]; followed by a uniformly random signal (values between ¡2 and +2) on [1; 2]; followed by a normally distributed random signal (mean 0 and st dev 1) on [2; 3]: Create this using 100 samples on each interval. Do all this in a script …le. Hand in the script and the graph.