DOC PREVIEW
TRINITY CSCI 2323 - Applying Matlab

This preview shows page 1-2 out of 7 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 71Applying Matlab 21-27-20102Opening Discussion■What did we talk about last class?■Do you have any questions about the reading?3Control Flow Constructs■Last time we looked at the for loop. We also have the following:While loopIf statements – includes if, else, end, and elseif.Switch-case – allows cases with multiple expressions and otherwise clause.Try-catch blocks for error handling. Variable lasterr gives information about the last error.■In general you can get away with only using loops and the if conditional. Switch is occasionally helpful and the try-catch is nice in situations where something might go wrong.4Examples of Control Flow■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.5Functions■Matlab functions are a bit different from what you are used to in other languages. They can take a variable number of arguments and return a variable number of arguments.■To return a value, we set a variable with the name specified on the first line of the function to the value we want to return. That is what will be returned when the function terminates.■You can also have local functions or nested functions. When either of these is used the main function must be terminated with end.■Function handles are also discussed in the book and they are worth noting.6Writing a Function■We have our Matlab code to do the iteration for a single pixel of the mandelbrot set. Now make an m-file and put that code into the m-file as a function that takes a point and returns how many iterations it went.■Let's try to write code that will plot up a full Mandelbrot set for us.■How could we do this better? Generally you want to avoid explicit loops in Matlab. What is the fewest number of loops we could get away with to make a Mandelbrot?7Closing Remarks■Remember to submit assignment #2


View Full Document

TRINITY CSCI 2323 - Applying Matlab

Documents in this Course
Load more
Download Applying Matlab
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Applying Matlab and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Applying Matlab 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?