Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 81Applying Matlab1-25-20102Opening Discussion■Do you have any questions about the quiz?■What did we talk about last class?■Do you have any questions about the reading?3Relational and Logic Operations■As we saw at the end of last class, Matlab supports relational arrays. You can do all your normal logical operations on logical arrays.■The logical arrays can be used for selection.■Make an array with two rows. One row is integers from -5 to 5, the other is the square of those values.■Now use a logical operation to make a new array that contains only the columns where the square is greater than 5.■Now do the same type of thing but only get squares greater than 10 or less than 5.4Flow Control■Matlab has control flow structures just like the imperative languages that you are used to.■The details can be a bit different though.5Examples of Flow Control■Write a few lines of code that will do Serpinski's triangle and put each new point in a single Nx2 array. Put 5000 points into it.■You can plot that array with the following:plot(data(:,1),data(:,2),'.')■Now write a loop that will do a Mandelbrot check for a single point. Have it loop until zn has a magnitude greater than 2 or you get through 100 iterations.6Functions■Matlab allows you to write functions in m-files.■You edit them just like you would an m-file script, but they have a particular syntax for passing in arguments.7Using Functions■Now make an m-file and put the code you wrote for the Mandelbrot into the m-file as a function that takes a point and returns how many iterations it went.■Lets close out the class trying to write code that will plot up a full Mandelbrot set for us.8Closing Comments■Assignment #2 is due on
View Full Document