Function M-Files

References:

  1. Hahn & Valentine, "Essential MATLAB for Engineers and Scientists", Fourth Edition, Chapter 10 up to section 10.3.3
  2. "Computer Science 01", section 8.6.
  3. Delores M. Etter, "Introduction to MATLAB, Second Edition", Section 3.6.

General

Syntax

        function [ outarg1, outarg2, ..., outargN ] = functionName( inarg1, inarg2, ..., inargM )
        % First comment line is reported by "lookfor"
        % Additional lines of first comment are reported by "help"
        .
        .	Matlab commands
        .
        outarg1 = . . .
        .
        .
        outargN = . . .
        .
        .
        .

Details

Example

Checking the Number of Arguments Passed In or Out

Subfunctions

Private Functions

P-Code Files

Function Handles

		function result = functionCaller( handle, x )
        
        	sinHandle = @sin;
        
        	result = feval( sinHandle, x ) + feval( @cos, x ) + feval( handle, x );
        
       	return;