Skip to Main Content Skip to Search
Product Documentation

Programming and Data Types

Data TypesNumeric, character, structures, cell arrays, and data type conversion
Data Type ConversionConvert one numeric type to another, numeric to string, string to numeric, structure to cell array, etc.
Operators and Special CharactersArithmetic, relational, and logical operators, and special characters
StringsCreate, identify, manipulate, parse, evaluate, and compare strings
Bit-Wise OperationsPerform set, shift, and, or, compare, etc. on specific bit fields
Logical OperationsEvaluate conditions, testing for true or false
Relational OperationsCompare values for equality, greater than, less than, etc.
Set OperationsFind set members, unions, intersections, etc.
Date and Time OperationsObtain information about dates and times
Programming in MATLABFunction/expression evaluation, timed execution, memory, program control, error handling, MEX programming

Data Types

Numeric TypesInteger and floating-point data
Characters and StringsCharacters and arrays of characters
StructuresData of varying types and sizes stored in fields of a structure
Cell ArraysData of varying types and sizes stored in cells of array
Map Container ObjectsSelect elements of Map container using indices of various data types
Function HandlesInvoke a function indirectly via handle
Java Classes and ObjectsAccess Java classes through MATLAB interface
Data Type IdentificationDetermine data type of a variable

Numeric Types

arrayfunApply function to each element of array
castCast variable to different data type
catConcatenate arrays along specified dimension
classDetermine class of object
findFind indices and values of nonzero elements
intmaxLargest value of specified integer type
intminSmallest value of specified integer type
ipermuteInverse permute dimensions of N-D array
isaDetermine whether input is object of given class
isequalTest arrays for equality
isequalwithequalnansTest arrays for equality, treating NaNs as equal
isfiniteArray elements that are finite
isinfArray elements that are infinite
isnanArray elements that are NaN
isnumericDetermine whether input is numeric array
isrealCheck if input is real array
permuteRearrange dimensions of N-D array
realmaxLargest positive floating-point number
realminSmallest positive normalized floating-point number
reshapeReshape array
squeezeRemove singleton dimensions
zerosCreate array of all zeros

Characters and Strings

See Strings for all string-related functions.

cellstrCreate cell array of strings from character array
charConvert to character array (string)
evalExecute string containing MATLAB expression
findstrFind string within another, longer string
isstrDetermine whether input is character array
sprintfFormat data into string
sscanfRead formatted data from string
strcatConcatenate strings horizontally
strfindFind one string within another
stringsString handling
strjustJustify character array
strmatchFind possible matches for string
strreadRead formatted data from string
strrepFind and replace substring
strtrimRemove leading and trailing white space from string
strvcatConcatenate strings vertically

Structures

arrayfunApply function to each element of array
cell2structConvert cell array to structure array
classDetermine class of object
dealDistribute inputs to outputs
fieldnamesField names of structure, or public fields of object
getfieldField of structure array
isaDetermine whether input is object of given class
isequalTest arrays for equality
isfieldDetermine whether input is structure array field
isstructDetermine whether input is structure array
orderfieldsOrder fields of structure array
rmfieldRemove fields from structure
setfieldAssign values to structure array field
structCreate structure array
struct2cellConvert structure to cell array
structfunApply function to each field of scalar structure

Cell Arrays

cellCreate cell array
cell2matConvert cell array to numeric array
cell2structConvert cell array to structure array
celldispCell array contents
cellfunApply function to each cell in cell array
cellplotGraphically display structure of cell array
cellstrCreate cell array of strings from character array
classDetermine class of object
dealDistribute inputs to outputs
isaDetermine whether input is object of given class
iscellDetermine whether input is cell array
iscellstrDetermine whether input is cell array of strings
isequalTest arrays for equality
mat2cellConvert array to cell array with potentially different sized cells
num2cellConvert array to cell array with consistently sized cells
struct2cellConvert structure to cell array

Map Container Objects

containers.MapMap values to unique keys
isKey (containers.Map)Determine if containers.Map object contains key
keys (containers.Map)Identify keys of containers.Map object
length (containers.Map)Length of containers.Map object
remove (containers.Map)Remove key-value pairs from containers.Map object
size (containers.Map)Size of containers.Map object
values (containers.Map)Identify values in containers.Map object

Function Handles

classDetermine class of object
fevalEvaluate function
func2strConstruct function name string from function handle
function_handle (@)Handle used in calling functions indirectly
functionsInformation about function handle
isaDetermine whether input is object of given class
isequalTest arrays for equality
str2funcConstruct function handle from function name string

Java Classes and Objects

cellCreate cell array
classDetermine class of object
clearRemove items from workspace, freeing up system memory
depfunList dependencies of function or P-file
existCheck existence of variable, function, folder, or class
fieldnamesField names of structure, or public fields of object
im2javaConvert image to Java image
importAdd package or class to current import list
inmemNames of functions, MEX-files, Sun Java classes in memory
isaDetermine whether input is object of given class
isjavaDetermine whether input is Sun Java object
javaaddpathAdd entries to dynamic Java class path
javaArrayConstruct Java array
javachkGenerate error message based on Java feature support
javaclasspathGet and set Java class path
javaMethodInvoke Sun Java method
javaMethodEDTInvoke Java method from Event Dispatch Thread (EDT)
javaObjectInvoke Sun Java constructor
javaObjectEDTJava object constructor on Event Dispatch Thread (EDT)
javarmpathRemove entries from dynamic Java class path
methodsClass method names
methodsviewView class methods
usejavaDetermine whether Sun Java feature is supported in MATLAB software
whichLocate functions and files

Data Type Identification

is*Detect state
isaDetermine whether input is object of given class
iscellDetermine whether input is cell array
iscellstrDetermine whether input is cell array of strings
ischarDetermine whether item is character array
isfieldDetermine whether input is structure array field
isfloatDetermine whether input is floating-point array
ishghandleTrue for Handle Graphics object handles
isintegerDetermine whether input is integer array
isjavaDetermine whether input is Sun Java object
islogicalDetermine whether input is logical array
isnumericDetermine whether input is numeric array
isobjectIs input MATLAB object
isrealCheck if input is real array
isstrDetermine whether input is character array
isstructDetermine whether input is structure array
validateattributesCheck validity of array
whoList variables in workspace
whosList variables in workspace, with sizes and types

Data Type Conversion

NumericConvert data of one numeric type to another numeric type
String to NumericConvert characters to numeric equivalent
Numeric to StringConvert numeric to character equivalent
Other ConversionsConvert to structure, cell array, function handle, etc.

Numeric

castCast variable to different data type
doubleConvert to double precision
int16Convert to 16-bit signed integer
int32Convert to 32-bit signed integer
int64Convert to 64-bit signed integer
int8Convert to 8-bit signed integer
singleConvert to single precision
typecastConvert data types without changing underlying data
uint16Convert to 16-bit unsigned integer
uint32Convert to 32-bit unsigned integer
uint64Convert to 64-bit unsigned integer
uint8Convert to 8-bit unsigned integer

String to Numeric

base2decConvert base N number string to decimal number
bin2decConvert binary number string to decimal number
castCast variable to different data type
hex2decConvert hexadecimal number string to decimal number
hex2numConvert hexadecimal number string to double-precision number
str2doubleConvert string to double-precision value
str2numConvert string to number
unicode2nativeConvert Unicode characters to numeric bytes

Numeric to String

castCast variable to different data type
charConvert to character array (string)
dec2baseConvert decimal to base N number in string
dec2binConvert decimal to binary number in string
dec2hexConvert decimal to hexadecimal number in string
int2strConvert integer to string
mat2strConvert matrix to string
native2unicodeConvert numeric bytes to Unicode characters
num2strConvert number to string

Other Conversions

cell2matConvert cell array to numeric array
cell2structConvert cell array to structure array
datestrConvert date and time to string format
func2strConstruct function name string from function handle
logicalConvert numeric values to logical
mat2cellConvert array to cell array with potentially different sized cells
num2cellConvert array to cell array with consistently sized cells
num2hexConvert singles and doubles to IEEE hexadecimal strings
str2funcConstruct function handle from function name string
str2matForm blank-padded character matrix from strings
struct2cellConvert structure to cell array

Operators and Special Characters

Arithmetic OperatorsPlus, minus, power, left and right divide, transpose, etc.
Relational OperatorsEqual to, greater than, less than or equal to, etc.
Logical OperatorsElement-wise and short circuit and, or, not
Special CharactersArray constructors, line continuation, comments, etc.

Arithmetic Operators

Arithmetic Operators + - * / \ ^ 'Matrix and array arithmetic
+Plus
-Minus
.Decimal point
=Assignment
*Matrix multiplication
/Matrix right division
\Matrix left division
^Matrix power
'Matrix transpose
.*Array multiplication (element-wise)
./Array right division (element-wise)
.\Array left division (element-wise)
.^Array power (element-wise)
.'Array transpose

Relational Operators

Relational Operators < > <= >= == ~=Relational operations
<Less than
<=Less than or equal to
>Greater than
>=Greater than or equal to
==Equal to
~=Not equal to

Logical Operators

See also Logical Operations for functions like xor, all, any, etc.

&&Logical AND
||Logical OR
&Logical AND for arrays
|Logical OR for arrays
~Logical NOT

Special Characters

Special Characters [ ] ( ) {} = ' . ... , ; : % ! @Special characters
:Create vectors, subscript arrays, specify for-loop iterations
( )Pass function arguments, prioritize operators
[ ]Construct array, concatenate elements, specify multiple outputs from function
{ }Construct cell array, index into cell array
.Insert decimal point, define structure field, reference methods of object
.( )Reference dynamic field of structure
..Reference parent directory
...Continue statement to next line
,Separate rows of array, separate function input/output arguments, separate commands
;Separate columns of array, suppress output from current command
%Insert comment line into code
%{ %}Insert block of comments into code
!Issue command to operating system
' 'Construct character array
@Construct function handle, reference class directory

Strings

Description of Strings in MATLABBasics of string handling in MATLAB
String CreationCreate strings, cell arrays of strings, concatenate strings together
String IdentificationIdentify characteristics of strings
String ManipulationConvert case, strip blanks, replace characters
String ParsingFormatted read, regular expressions, locate substrings
String EvaluationEvaluate stated expression in string
String ComparisonCompare contents of strings

Description of Strings in MATLAB

stringsString handling

String Creation

blanksCreate string of blank characters
cellstrCreate cell array of strings from character array
charConvert to character array (string)
sprintfFormat data into string
strcatConcatenate strings horizontally
strvcatConcatenate strings vertically

String Identification

isaDetermine whether input is object of given class
iscellstrDetermine whether input is cell array of strings
ischarDetermine whether item is character array
isletterArray elements that are alphabetic letters
isspaceArray elements that are space characters
isstrpropDetermine whether string is of specified category
validatestringCheck validity of text string

String Manipulation

deblankStrip trailing blanks from end of string
lowerConvert string to lowercase
strjustJustify character array
strrepFind and replace substring
strtrimRemove leading and trailing white space from string
upperConvert string to uppercase

String Parsing

findstrFind string within another, longer string
regexprepReplace string using regular expression
regexptranslateTranslate string into regular expression
sscanfRead formatted data from string
strfindFind one string within another
strreadRead formatted data from string
strtokSelected parts of string

String Evaluation

evalExecute string containing MATLAB expression
evalcEvaluate MATLAB expression with capture
evalinExecute MATLAB expression in specified workspace

String Comparison

strmatchFind possible matches for string

Bit-Wise Operations

bitandBit-wise AND
bitcmpBitwise complement
bitgetBit at specified position
bitmaxMaximum double-precision floating-point integer
bitorBit-wise OR
bitsetSet bit at specified position
bitshiftShift bits specified number of places
bitxorBit-wise XOR
swapbytesSwap byte ordering

Logical Operations

allDetermine whether all array elements are nonzero or true
andFind logical AND of array or scalar inputs
anyDetermine whether any array elements are nonzero
falseLogical 0 (false)
findFind indices and values of nonzero elements
isaDetermine whether input is object of given class
iskeywordDetermine whether input is MATLAB keyword
isvarnameDetermine whether input is valid variable name
logicalConvert numeric values to logical
notFind logical NOT of array or scalar input
orFind logical OR of array or scalar inputs
trueLogical 1 (true)
xorLogical exclusive-OR


See Operators and Special Characters for logical operators.

Relational Operations

eqTest for equality
geTest for greater than or equal to
gtTest for greater than
leTest for less than or equal to
ltTest for less than
neTest for inequality


See Operators and Special Characters for relational operators.

Set Operations

intersectFind set intersection of two vectors
ismemberArray elements that are members of set
issortedDetermine whether set elements are in sorted order
setdiffFind set difference of two vectors
setxorFind set exclusive OR of two vectors
unionFind set union of two vectors
uniqueFind unique elements of vector

Date and Time Operations

addtodateModify date number by field
calendarCalendar for specified month
clockCurrent time as date vector
cputimeElapsed CPU time
dateCurrent date string
datenumConvert date and time to serial date number
datestrConvert date and time to string format
datevecConvert date and time to vector of components
eomdayLast day of month
etimeTime elapsed between date vectors
nowCurrent date and time
weekdayDay of week

Programming in MATLAB

Functions and ScriptsWrite and execute program code, interact with caller, check input and output values, dependencies
EvaluationEvaluate expression in string, apply function to array, run script file, etc.
TimerSchedule execution of MATLAB commands
Variables and Functions in MemoryList, lock, or clear functions in memory, construct variable names, consolidate workspaces, refresh caches
Control FlowConditional control, loop control, error control, program termination
Error HandlingGenerate warnings and errors, test for and catch errors, capture data on cause of error, warning control
MEX ProgrammingCompile MEX function from C or Fortran code, list MEX-files in memory, debug MEX-files

Functions and Scripts

addOptional (inputParser)Add optional argument to Input Parser scheme
addParamValue (inputParser)Add parameter name/value argument to Input Parser scheme
addRequired (inputParser)Add required argument to Input Parser scheme
createCopy (inputParser)Create copy of inputParser object
depdirList dependent folders for function or P-file
depfunList dependencies of function or P-file
echoDisplay statements during function execution
endTerminate block of code, or indicate last array index
functionDeclare function
inputRequest user input
inputnameVariable name of function input
inputParserConstruct input parser object
mfilenameFile name of currently running function
namelengthmaxMaximum identifier length
nargchkValidate number of input arguments
narginNumber of function input arguments
narginchkValidate number of input arguments
nargoutNumber of function output arguments
nargoutchkValidate number of output arguments
onCleanupCleanup tasks at function completion
parse (inputParser)Parse and validate named inputs
pcodeCreate protected function file
scriptSequence of MATLAB statements in file
syntaxTwo ways to call MATLAB functions
vararginVariable length input argument list
varargoutVariable length output argument list

Evaluation

ansMost recent answer
arrayfunApply function to each element of array
assertGenerate error when condition is violated
builtinExecute built-in function from overloaded method
cellfunApply function to each cell in cell array
echoDisplay statements during function execution
evalExecute string containing MATLAB expression
evalcEvaluate MATLAB expression with capture
evalinExecute MATLAB expression in specified workspace
fevalEvaluate function
iskeywordDetermine whether input is MATLAB keyword
isvarnameDetermine whether input is valid variable name
pauseHalt execution temporarily
runRun script that is not on current path
scriptSequence of MATLAB statements in file
structfunApply function to each field of scalar structure
symvarDetermine symbolic variables in expression
ticStart clock to measure performance
tocStop clock to measure performance

Timer

delete (timer)Remove timer object from memory
disp (timer)Information about timer object
get (timer)Timer object properties
isvalid (timer)Determine whether timer object is valid
set (timer)Configure or display timer object properties
startStart timer(s) running
startatStart timer(s) running at specified time
stopStop timer(s)
timerConstruct timer object
timerfindFind timer objects
timerfindallFind timer objects, including invisible objects
waitWait until timer stops running

Variables and Functions in Memory

ansMost recent answer
assigninAssign value to variable in specified workspace
clearvarsClear variables from memory
datatipinfoProduce short description of input variable
genvarnameConstruct valid variable name from string
globalDeclare global variables
inmemNames of functions, MEX-files, Sun Java classes in memory
isglobalDetermine whether input is global variable
memoryDisplay memory information
mislockedDetermine if function is locked in memory
mlockPrevent clearing function from memory
munlockAllow clearing functions from memory
namelengthmaxMaximum identifier length
packConsolidate workspace memory
persistentDefine persistent variable
rehashRefresh function and file system path caches

Control Flow

breakTerminate execution of for or while loop
continuePass control to next iteration of for or while loop
endTerminate block of code, or indicate last array index
errorDisplay message and abort function
forExecute statements specified number of times
if/elseif/elseExecute statements if condition is true
parforParallel for loop
returnReturn to invoking function
switch/case/otherwiseSwitch among several cases based on expression
try/catchExecute statements and catch resulting errors
whileRepeatedly execute statements while condition is true

Error Handling

addCause (MException)Record additional causes of exception
assertGenerate error when condition is violated
disp (MException)Display MException object
eq (MException)Compare scalar MException objects for equality
errorDisplay message and abort function
ferrorInformation about file I/O errors
getReport (MException)Get error message for exception
isequal (MException)Compare scalar MException objects for equality
last (MException)Last uncaught exception
lastwarnLast warning message
MExceptionCapture error information
ne (MException)Compare scalar MException objects for inequality
rethrowReissue error
rethrow (MException)Reissue existing exception
throw (MException)Issue exception and terminate function
throwAsCaller (MException)Throw exception as if from calling function
try/catchExecute statements and catch resulting errors
warningWarning message

MEX Programming

dbmexEnable MEX-file debugging (on UNIX platforms)
inmemNames of functions, MEX-files, Sun Java classes in memory
mexCompile MEX-function from C/C++ or Fortran source code
mex.getCompilerConfigurationsGet compiler configuration information for building MEX-files
mexextBinary MEX-file name extension
  


» Learn more
» Download free kit
» Get trial software

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS