Docsity

Exam Study Guide for MATLAB Programming - Numerical Methods | CS 257, Study notes of Computer Science

Toggle sidebar
bg1
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.
pf2

Partial preview of the text

Download Exam Study Guide for MATLAB Programming - Numerical Methods | CS 257 and more Study notes Computer Science in PDF only on Docsity!

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, and if...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.

Study Guide for Matlab Programming 2

Developing Mastery

Working toward mastery of solving systems of equations you will need to

  1. Use global variables
  2. Use array indexing instead of loops to select elements from a matrix.
  3. Use logical indexing and logical functions instead of loops to select ele- ments from matrix.
  4. Use fprintf to write data to a file.
  5. Use fprintf to load data from a file

This document was created by Gerald Recktenwald. It is in the public domain.