MATLAB Programming

MATLAB Programming MATLAB Programming

cda.psych.uiuc.edu
from cda.psych.uiuc.edu More from this publisher
23.06.2015 Views

Converting Between Strings and Cell Arrays ........... 12-31 Search and Replace Using Regular Expressions ......... 12-31 Evaluating Expressions ............................ 12-33 Find Alternatives to Using eval ...................... 12-33 Assigning to a Series of Variables .................... 12-33 Short-Circuit Logical Operators ...................... 12-33 Changing the Counter Variable within a for Loop ....... 12-34 MATLAB Path ..................................... 12-35 Precedence Rules .................................. 12-35 File Precedence ................................... 12-36 Adding a Directory to the Search Path ................ 12-36 Handles to Functions Not on the Path ................. 12-36 Making Toolbox File Changes Visible to MATLAB ....... 12-37 Making Nontoolbox File Changes Visible to MATLAB .... 12-38 Change Notification on Windows ..................... 12-38 Program Control .................................. 12-39 Using break, continue, and return .................... 12-39 Using switch Versus if .............................. 12-40 MATLAB case Evaluates Strings ..................... 12-40 Multiple Conditions in a case Statement ............... 12-40 Implicit Break in switch-case ........................ 12-40 Variable Scope in a switch .......................... 12-41 Catching Errors with try-catch ...................... 12-41 Nested try-catch Blocks ............................ 12-42 Forcing an Early Return from a Function .............. 12-42 Save and Load ..................................... 12-43 Saving Data from the Workspace ..................... 12-43 Loading Data into the Workspace .................... 12-43 Viewing Variables in a MAT-File ..................... 12-44 Appending to a MAT-File ........................... 12-44 SaveandLoadonStartuporQuit .................... 12-45 Saving to an ASCII File ............................ 12-45 Files and Filenames ................................ 12-46 Naming M-files ................................... 12-46 Naming Other Files ............................... 12-46 Passing Filenames as Arguments .................... 12-47 Passing Filenames to ASCII Files .................... 12-47 xxii Contents

Determining Filenames at Run-Time ................. 12-47 Returning the Size of a File ......................... 12-47 Input/Output ...................................... 12-49 File I/O Function Overview ......................... 12-49 Common I/O Functions ............................. 12-49 Readable File Formats ............................. 12-50 Using the Import Wizard ........................... 12-50 Loading Mixed Format Data ........................ 12-50 Reading Files with Different Formats ................. 12-51 Reading ASCII Data into a Cell Array ................. 12-51 Interactive Input into Your Program .................. 12-51 Starting MATLAB .................................. 12-52 Getting MATLAB to Start Up Faster .................. 12-52 Operating System Compatibility .................... 12-53 Executing O/S Commands from MATLAB ............. 12-53 Searching Text with grep ........................... 12-53 Constructing Paths and Filenames ................... 12-53 Finding the MATLAB Root Directory ................. 12-54 Temporary Directories and Filenames ................. 12-54 Demos ............................................ 12-55 Demos Available with MATLAB ..................... 12-55 For More Information .............................. 12-56 Current CSSM .................................... 12-56 Archived CSSM ................................... 12-56 MATLAB Technical Support ......................... 12-56 Tech Notes ....................................... 12-56 MATLAB Central ................................. 12-56 MATLAB Newsletters (Digest, News & Notes) .......... 12-56 MATLAB Documentation ........................... 12-56 MATLAB Index of Examples ........................ 12-56 xxiii

Converting Between Strings and Cell Arrays ........... 12-31<br />

Search and Replace Using Regular Expressions ......... 12-31<br />

Evaluating Expressions ............................ 12-33<br />

Find Alternatives to Using eval ...................... 12-33<br />

Assigning to a Series of Variables .................... 12-33<br />

Short-Circuit Logical Operators ...................... 12-33<br />

Changing the Counter Variable within a for Loop ....... 12-34<br />

<strong>MATLAB</strong> Path ..................................... 12-35<br />

Precedence Rules .................................. 12-35<br />

File Precedence ................................... 12-36<br />

Adding a Directory to the Search Path ................ 12-36<br />

Handles to Functions Not on the Path ................. 12-36<br />

Making Toolbox File Changes Visible to <strong>MATLAB</strong> ....... 12-37<br />

Making Nontoolbox File Changes Visible to <strong>MATLAB</strong> .... 12-38<br />

Change Notification on Windows ..................... 12-38<br />

Program Control .................................. 12-39<br />

Using break, continue, and return .................... 12-39<br />

Using switch Versus if .............................. 12-40<br />

<strong>MATLAB</strong> case Evaluates Strings ..................... 12-40<br />

Multiple Conditions in a case Statement ............... 12-40<br />

Implicit Break in switch-case ........................ 12-40<br />

Variable Scope in a switch .......................... 12-41<br />

Catching Errors with try-catch ...................... 12-41<br />

Nested try-catch Blocks ............................ 12-42<br />

Forcing an Early Return from a Function .............. 12-42<br />

Save and Load ..................................... 12-43<br />

Saving Data from the Workspace ..................... 12-43<br />

Loading Data into the Workspace .................... 12-43<br />

Viewing Variables in a MAT-File ..................... 12-44<br />

Appending to a MAT-File ........................... 12-44<br />

SaveandLoadonStartuporQuit .................... 12-45<br />

Saving to an ASCII File ............................ 12-45<br />

Files and Filenames ................................ 12-46<br />

Naming M-files ................................... 12-46<br />

Naming Other Files ............................... 12-46<br />

Passing Filenames as Arguments .................... 12-47<br />

Passing Filenames to ASCII Files .................... 12-47<br />

xxii<br />

Contents

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

Saved successfully!

Ooh no, something went wrong!