
Study Guide for Matlab Programming 1
Bare Essentials
At the end of this chapter you should be able to
1. Edit and run an m-file (both functions and scripts).
2. Identify the key differences between scripts and functions.
3. Create a function with one, two or more input parameters and one, two
or more output parameters.
4. Use comment statements to add documentation to scripts and functions.
5. Use disp to print a string and a matrix to the command window.
6. Use relational operators (<,<=,>,>=,~=), and logical operators (&,|,~).
7. Use if...end,if...elseif...end,andif...elseif...else...end con-
structs.
8. Write a for loop to access each element of a vector of arbitrary length.
9. Use a while loop to iterate until a convergence tolerance is met.
10. Know the difference between break and return, and know how and where
to use each.
11. Use disp to print string messages from within an m-file
12. Use disp to print the values in vectors and matrices from within an m-file
An Expanded Core of Knowledge
After mastering the bare essentials you should move on to a deeper understand-
ing of the fundamentals. Doing so involves being able to
1. Use fprintf for formatted output.
2. Use a one-line if...end construct.
3. Write functions having variable numbers of input and output arguments.
4. Use a switch construct.
5. Preallocate memory for matrices, and know why and when this is advan-
tageous.
6. Replace basic loops with vectorized statements.
7. Use colon notation to perform vectorized copy operations.
8. Use feval. Know how to pass a function name as an input parameter to
another function.
This document was created by Gerald Recktenwald. It is in the public domain.