23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Passing Arguments in a Cell Array ................... 12-18<br />

Program Development ............................. 12-19<br />

Planning the Program .............................. 12-19<br />

Using Pseudo-Code ................................ 12-19<br />

Selecting the Right Data Structures .................. 12-19<br />

General Coding Practices ........................... 12-20<br />

Naming a Function Uniquely ........................ 12-20<br />

The Importance of Comments ....................... 12-20<br />

Coding in Steps ................................... 12-21<br />

Making Modifications in Steps ....................... 12-21<br />

Functions with One Calling Function ................. 12-21<br />

Testing the Final Program .......................... 12-21<br />

Debugging ........................................ 12-22<br />

The <strong>MATLAB</strong> Debug Functions ...................... 12-22<br />

More Debug Functions ............................. 12-22<br />

The <strong>MATLAB</strong> Graphical Debugger ................... 12-23<br />

A Quick Way to Examine Variables ................... 12-23<br />

Setting Breakpoints from the Command Line .......... 12-24<br />

Finding Line Numbers to Set Breakpoints ............. 12-24<br />

Stopping Execution on an Error or Warning ............ 12-24<br />

Locating an Error from the Error Message ............. 12-24<br />

Using Warnings to Help Debug ...................... 12-25<br />

Making Code Execution Visible ...................... 12-25<br />

Debugging Scripts ................................. 12-25<br />

Variables .......................................... 12-26<br />

Rules for Variable Names ........................... 12-26<br />

Making Sure Variable Names Are Valid ............... 12-26<br />

Don’t Use Function Names for Variables ............... 12-27<br />

Checking for Reserved Keywords ..................... 12-27<br />

Avoid Using i and j for Variables ..................... 12-28<br />

Avoid Overwriting Variables in Scripts ................ 12-28<br />

Persistent Variables ............................... 12-28<br />

Protecting Persistent Variables ...................... 12-28<br />

Global Variables .................................. 12-29<br />

Strings ........................................... 12-30<br />

Creating Strings with Concatenation ................. 12-30<br />

Comparing Methods of Concatenation ................. 12-30<br />

Store Arrays of Strings in a Cell Array ................ 12-31<br />

xxi

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!