23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

M-File Scripts .................................... 4-18<br />

M-File Functions .................................. 4-19<br />

Types of Functions ................................ 4-20<br />

Identifying Dependencies ........................... 4-21<br />

Function Handles .................................. 4-23<br />

Constructing a Function Handle ..................... 4-23<br />

Calling a Function Using Its Handle .................. 4-24<br />

Functions That Operate on Function Handles .......... 4-26<br />

Comparing Function Handles ....................... 4-26<br />

Additional Information on Function Handles ........... 4-31<br />

Function Arguments ............................... 4-33<br />

Checking the Number of Input Arguments ............. 4-33<br />

Passing Variable Numbers of Arguments .............. 4-35<br />

Parsing Inputs with inputParser ..................... 4-37<br />

Passing Optional Arguments to Nested Functions ....... 4-48<br />

Returning Modified Input Arguments ................. 4-51<br />

Calling Functions .................................. 4-53<br />

What Happens When You Call a Function ............. 4-53<br />

Determining Which Function Is Called ................ 4-54<br />

<strong>MATLAB</strong> Calling Syntax ........................... 4-57<br />

Passing Certain Argument Types .................... 4-61<br />

Passing Arguments in Structures or Cell Arrays ........ 4-63<br />

Assigning Output Arguments ........................ 4-65<br />

Calling External Functions ......................... 4-67<br />

Running External Programs ........................ 4-68<br />

5<br />

Types of Functions<br />

Overview of <strong>MATLAB</strong> Function Types ............... 5-2<br />

Anonymous Functions ............................. 5-3<br />

Constructing an Anonymous Function ................ 5-3<br />

Arrays of Anonymous Functions ..................... 5-6<br />

Outputs from Anonymous Functions .................. 5-7<br />

Variables Used in the Expression .................... 5-8<br />

xi

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

Saved successfully!

Ooh no, something went wrong!