MATLAB Function Reference    

Programming in MATLAB

M-File Functions and Scripts

( ) Pass function arguments
% Insert comment line into code
... Continue statement to next line
depfun List dependent functions of M-file or P-file
depdir List dependent directories of M-file or P-file
function Function M-files
input Request user input
inputname Input argument name
mfilename Name of currently running M-file
namelengthmax Return maximum identifier length
nargin Number of function input arguments
nargout Number of function output arguments
nargchk Check number of input arguments
nargoutchk Validate number of output arguments
pcode Create preparsed pseudocode file (P-file)
script Describes script M-file
varargin Accept variable number of arguments
varargout Return variable number of arguments

Evaluation of Expressions and Functions

builtin Execute builtin function from overloaded method
cellfun Apply function to each element in cell array
eval Interpret strings containing MATLAB expressions
evalc Evaluate MATLAB expression with capture
evalin Evaluate expression in workspace
feval Evaluate function
iskeyword Determine if item is MATLAB keyword
isvarname Determine if item is valid variable name
pause Halt execution temporarily
run Run script that is not on current path
script Describes script M-file
symvar Determine symbolic variables in expression
tic, toc Stopwatch timer

Timer Functions

delete Delete timer object from memory
disp Display information about timer object
get Retrieve information about timer object properties
isvalid Determine if timer object is valid
set Display or set timer object properties
start Start a timer
startat Start a timer at a specific timer
stop Stop a timer
timer Create a timer object
timerfind Return an array of all timer object in memory
wait Block command line until timer completes

Variables and Functions in Memory

assignin Assign value to workspace variable
global Define global variables
inmem Return names of functions in memory
isglobal Determine if item is global variable
mislocked True if M-file cannot be cleared
mlock Prevent clearing M-file from memory
munlock Allow clearing M-file from memory
namelengthmax Return maximum identifier length
pack Consolidate workspace memory
persistent Define persistent variable
rehash Refresh function and file system caches

Control Flow

break Terminate execution of for loop or while loop
case Case switch
catch Begin catch block
continue Pass control to next iteration of for or while loop
else Conditionally execute statements
elseif Conditionally execute statements
end Terminate conditional statements, or indicate last index
error Display error messages
for Repeat statements specific number of times
if Conditionally execute statements
otherwise Default part of switch statement
return Return to invoking function
switch Switch among several cases based on expression
try Begin try block
while Repeat statements indefinite number of times

Function Handles

class Return object's class name (e.g. function_handle)
feval Evaluate function
function_handle Describes function handle data type
functions Return information about function handle
func2str Constructs function name string from function handle
isa Detect object of given class (e.g. function_handle)
isequal Determine if function handles are equal
str2func Constructs function handle from function name string

Object-Oriented Programming

MATLAB Classes and Objects
class Create object or return class of object
fieldnames List public fields belonging to object,
inferiorto Establish inferior class relationship
isa Detect object of given class
isobject Determine if item is MATLAB OOPs object
loadobj User-defined extension of load function for user objects
methods Display method names
methodsview Displays information on all methods implemented by class
saveobj User-defined extension of save function for user objects
subsasgn Overloaded method for A(I)=B, A{I}=B, and A.field=B
subsindex Overloaded method for X(A)
subsref Overloaded method for A(I), A{I} and A.field
substruct Create structure argument for subsasgn or subsref
superiorto Establish superior class relationship
Java Classes and Objects
cell Convert Java array object to cell array
class Return class name of Java object
clear Clear Java packages import list
depfun List Java classes used by M-file
exist Detect if item is Java class
fieldnames List public fields belonging to object
im2java Convert image to instance of Java image object
import Add package or class to current Java import list
inmem List names of Java classes loaded into memory
isa Detect object of given class
isjava Determine whether object is Java object
javaArray Constructs Java array
javaMethod Invokes Java method
javaObject Constructs Java object
methods Display methods belonging to class
methodsview Display information on all methods implemented by class
which Display package and class name for method

Error Handling

catch Begin catch block of try/catch statement
error Display error message
ferror Query MATLAB about errors in file input or output
lasterr Return last error message generated by MATLAB
lasterror Last error message and related information
lastwarn Return last warning message issued by MATLAB
rethrow Reissue error
try Begin try block of try/catch statement
warning Display warning message

MEX Programming

dbmex Enable MEX-file debugging
inmem Return names of currently loaded MEX-files
mex Compile MEX-function from C or Fortran source code
mexext Return MEX-filename extension

  Operators and Operations File I/O