DOC PREVIEW
TRINITY CSCI 2323 - Applying Matlab

This preview shows page 1-2-3 out of 9 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 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 9 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 9 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1Applying Matlab 29-12-20052Opening Discussion■So were you able to write a function that does the Mandelbrot calculation? Did you get a plot of the function? You should be able to do these things with stuff we talked about last time, but it is a bit tricky. You can get a better plot if you use 3-D plotting methods.3Functions■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.4Multidimensional Arrays■Arrays in Matlab can have more than 2 dimensions to them.■We aren't going to deal with these much in this course and your book doesn't really deal with them outside of this one chapter either.5Numeric Data Types■By default, everything in Matlab is a double. However, you can force things to be other types.■Integer types can be signed or unsigned with 8, 16, 32, or 64 bits. When you construct an array with one of the construction methods, you can pass in a string giving the integer type. The class function lets you see the type of something that you have.■You can also do a casting like operation to make something a particular type.■If you want, there are also single precision floating point numbers.6Cell Arrays■You make these with {} or the cell function. They don't have to be rectangular and they can hold any data. Each cell can hold a different type of data.■We can index into cell arrays with {} as well. If you index a cell array with () you get a cell containing data. If you use {} you get the data that was in the cell.■Multiple elements can't normally be pulled out with content addressing unless you put them into multiple variables with a comma separated list.■Anything that produces multiple cells will be turned into a comma separated list. This can be difficult to get your brain around.7Structures■You can use the dot notation to put fields into a variable to make a structure. Unlike normal imperative languages, the format of the structure isn't predefined.■Matlab deals with arrays of structures just like numeric arrays.■The struct function can build arrays of structures from existing cell arrays.■You can pull out all the values of certain field with 'dynamic addressing'.8Strings■Like most other languages, Matlab does give you the ability to use strings, though that isn't a real strength.■A Matlab string is simply a row array of characters.■A downside of this is that an array with multiple strings must have all the strings be the same length. The char function can help with that.■You can also convert from numbers to strings and back with str2num and num2str.■Matlab also has fprintf and sprintf functions that work much like the C functions.■Similarly, sscanf will pull numbers out of strings.■eval and evalc let you process a string like it were a Matlab function.9Reminders■Assignment #3 is due on


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?