Programming and Data Types    

Symbols 

%
for comment lines 19
for H1 and help text lines 18
& 37
@ 155
| 37
~ 37
~= 36

accuracy of calculations 29
adding
cells to cell arrays 142
fields to structure arrays 131
aggregation 219
AND operator, rules for evaluating 38
ans 29
answer, assigned to ans 29
arguments
checking number of 22
defined for function 17
order
varargin, varargout 24, 26 <1> <2>
passing 22
passing by reference 22
passing by value 22
passing variable number 24
arithmetic expressions 34
arithmetic operators
overloading 211
using 34
arrays
cell array of strings 94
character 91
dimensions
inverse permutation 115
indexing 59
multidimensional 105
numeric
converting to cell array 151
of strings 92
storage 59
assignment statements
building structure arrays with 126
local and global variables 27
automatic scalar expansion 35

base (numeric), converting 101
base date 71
base number conversion 90
binary from decimal conversion 101
blanks
finding in string arrays 98
removing from strings 93

C++ and MATLAB OOP 190
caching
MATLAB directory 14
MATLAB/toolbox directory 14
calling context 22
calling MATLAB functions
compiling for later use 21
how MATLAB searches for functions 20
storing as pseudocode 21
canonical class 191
case 45
case conversion 89
cat 104, 109, 120 <1> <2> <3>
catch
for error handling 67
cell
indexing 141
accessing a subset of cells 145
cell arrays 140
accessing a subset of cells 145
accessing data 144
applying functions to 148
cell indexing 141
concatenating 143
content indexing 142
converting to numeric array 151
creating 141
using assignments 141
with cells function 144
with curly braces 143
deleting cells 145
deleting dimensions 145
displaying 142
expanding 142
flat 150
indexing 142
multidimensional 120
nested 150
building with the cells function 150
indexing 151
of strings 94
comparing strings 97
of structures 152
organizing data 148
overview 140
preallocating 81, 144 <1> <2>
replacing comma-separated list with 146
reshaping 146
visualizing 142
cell data type 32
celldisp 142
cellplot 142
cells
building nested arrays with 150
preallocating empty arrays with 141, 144 <1> <2>
char data type 32
character arrays 91
categorizing characters of 98
comparing 96
comparing values on cell arrays 97
concatenating 62
conversion 89, 101 <1> <2>
converting to cell arrays 94
creating 91
delimiting character 99
evaluating 62, 102 <1> <2>
finding a substring 99
functions that test 88
in cell arrays 94
operations 89
padding for equal row length 92
removing trailing blanks 93
representation 91
scalar 97
searching and replacing 99
token 99
two-dimensional 92
using relational operators on 97
characters
corresponding ASCII values 93
finding in string 98
class directories 189
class function 193
classes 30
clearing definition 189
constructor method 192
debugging 188
designing 191
Java 32
methods required by MATLAB 191
object-oriented methods 185
overview 185
clear 21, 82 <1> <2>
colon operator 34
for multidimensional array subscripting 111
indexing a page with 117
scalar expansion with 107
to access subsets of cells 145
column vector
indexing as 59
comma to separate function arguments 17
comma-separated list
using cell arrays 146
comments in code 19
comparing
strings 96
complex conjugate transpose operator 34
computational functions
applying to cell arrays 148
applying to multidimensional arrays 116
applying to structure fields 131
in M-file 12
computer 29
computer type 29
concatenating
cell arrays 143
matrices 58
strings 62
conditional statements 22
constructor methods 192
guidelines 192
using class in 193
containment 219
content indexing 142
to access cell contents 144
Contents.m file 13
continue 49
conv 147
converter methods 202, 207 <1> <2>
converting
base numbers 90
cases of strings 89
dates 70
numbers 101
strings 89, 101 <1> <2>
cos 15
creating
cell array 141
multidimensional array 106
string array 92
strings 91
structure array 126
cross 116
curly braces
for cell array indexing 141, 143 <1> <2>
to build cell arrays 143
to nest cell arrays 150

data class hierarchy 186
data organization
cell arrays 148
multidimensional arrays 118
structure arrays 133
data types 30
cell 32
char 32
classes 186
double 32
single 31
sparse 32
sparse matrices 30
struct 32
uint 32
user-defined 186
UserObject 32
date 75
datenum 72, 73 <1> <2>
dates
base 71
conversions 72
formats 70
handling and converting 70
number 71
string, vector of input 73
datestr 72, 73 <1> <2>
datevec 72
deblank 93
debugging class methods 188
decimal representation
to binary 101
to hexadecimal 101
default function 169
deleting
cells from cell array 145
fields from structure arrays 131
matrix rows and columns 57
deletion operator 57
delimiter in string 99
dim argument for cat 109
dimensions
deleting 145
permuting 114
removing singleton 113
directories
adding to path 189
class 189
Contents.m file 13
help for 13
MATLAB
caching 14
private 53, 188 <1> <2>
disp 138
dispatch type 250
dispatching priority 20
display method 194
examples 195
displaying
cell arrays 142
error and warning messages 68
field names for structure array 127
double data type 32
double-precision matrix 30

editor
accessing 13
for creating M-files 11, 13 <1> <2>
eig 117
element-by-element organization for structures 136
else, elseif 43, 44 <1> <2>
empty arrays
and if statement 45
and relational operators 37
and while loops 47
empty matrices 65
end method 200
eps 29
epsilon 29
equal to operator 36
error 16
errors 67
displaying 68
handling 67
eval
for error handling 67
evaluating
string containing function name 62
string containing MATLAB code 102
string containing MATLAB expression 62
examples
checking number of function arguments 22
container class 236
for 48
function 16
if 44
inheritance 220
M-file for structure array 133
polynomial class 206
script 15
switch 46
vectorization 79
while 47
exclusive OR operator 39
execution,pausing 77
expanding
cell arrays 142
structure arrays 126
expressions
arithmetic 34
involving empty arrays 37
logical 37
most recent answer 29
overloading 203
relational 36
scalar expansion with 35
external program, running from MATLAB 78

feval
using on function handles 157, 163 <1> <2>
using on function name strings 182
fieldnames 127
fields 125, 126 <1> <2>
accessing data within 128
accessing with getfield 130
adding to structure array 131
applying functions to 131
all like-named fields 132
assigning data to 126
assigning with setfield 130
deleting from structures 131
indexing within 129
names 127
size 131
writing M-files for 132
fields 127
find function
and subscripting 40
finding
substring within a string 99
floating-point number
largest 29
smallest 29
floating-point relative accuracy 29
flow control 43
catch 50
continue 49
else 43
elseif 43
for 48
if 43
return 50
switch 45
try 50
while 47
for 48, 151 <1> <2>
example 48
indexing 48
nested 48
syntax 48
format
date 70
fragmentation, reducing 82
func2str
description 175
example 175
function definition line 12, 17 <1> <2>
for subfunction 51
function handles 32, 155 <1> <2>
benefits of 157
constructing 161
converting from function name string 176
converting to function name string 175
effect on performance 159
error conditions 180
evaluating a nonscalar function handle 181
including path in the constructor 180
nonexistent function 180
evaluating 163
finding the binding functions 167
for subfunctions, private functions 158
maximum name length 161
operations on 175
overloading 157, 163, 172 <1> <2> <3>
overview of 156
passing 157
saving and loading 179
testing for data type 177
testing for equality 177
types
constructor 172
overloaded 172
private 174
simple 171
subfunction 173
function name string
converting from function handle 175
converting to function handle 176
function workspace 22
functions 16
applying
to multidimensional structure arrays 122
to structure contents 131
applying to cell arrays 148
arguments
passing variable number of 24
body 12, 18 <1> <2>
calling 21
calling context 22
characteristics 11
class 193
clearing from memory 21
computational, applying to structure fields 131
contents 17
converters 207
creating arrays with 108
default 169
dispatching priority 20
example 16
executing function name string 62
inferiorto 248
isa 193
logical 39
multiple output values 17
naming 19
resolution 20
nested 83
optimization 79
order of arguments
varargin, varargout 24, 26 <1> <2>
overloaded methods 170
overloading 203, 205, 213 <1> <2> <3>
primary 51
private 53
storing as pseudocode 21
subassign 199
subfunction 51
subsref 196
superiorto 248
which 252
functions command
description 167
for constructor function handles 172
for overloaded function handles 172
for private function handles 174
for simple function handles 171
for subfunction handles 173
return fields 168

get method 195
getfield 130
global variables 27
rules for use 28
greater than operator 36
greater than or equal to operator 36

H1 line 12, 18 <1> <2>
and help command 12
and lookfor command 12
help 18
and H1 line 12
help text 12
hexadecimal, converting from decimal 101
hierarchy of data classes 186

if 43
and empty arrays 45
example 44
nested 44
imaginary unit 29
indexed reference 196
indexing 54
advanced 59
cell array 141
content 142
for loops 48
multidimensional arrays 111
nested cell arrays 151
nested structure arrays 139
structures within cell arrays 153
within structure fields 129
indices, how MATLAB calculates 61
Inf 29
inferiorto function 248
infinity (represented in MATLAB) 29
inheritance
example class 220
multiple 218
simple 217
input
from keyboard 77
obtaining from M-file 77
integers, changing to strings 101
interactive user input 77
inverse permutation of array dimensions 115
ipermute 104, 115 <1> <2>
isa 193
using with function handles 177
isempty 37
isequal
using with function handles 177
isinf 40
isnan 40

Java and MATLAB OOP 190

lasterr 67
and error handling 67
less than operator 36
less than or equal to operator 36
load 82
function handles 179
loading objects 242
loadobj example 244
local variables 27
logical expressions 37
and subscripting 40
logical functions 39
logical operators 37
rules for evaluation 38
lookfor 12, 18 <1> <2>
and H1 line 12
loops
for 48
while 47

MATLAB
data type classes 186
programming
functions 16
M-files 11
quick start 11
scripts 15
structures 190
version 29
matrices
accessing multiple elements 55
accessing single elements 54
advanced indexing 59
concatenating 58
deleting rows and columns 57
empty 65
expanding 56
sparse 30
matrix
as index for for loops 48
double-precision 30
power operator 35
single-precision 30
See also matrices
mean 116
memory
allocating for variables 84
function workspace 22
management 82
Out of Memory message 86
reducing fragmentation 82
methods 185
converters 202
determining which is called 252
display 194
end 200
get 195
invoking on objects 187
listing 215
overloaded 170
precedence 249
required by MATLAB 191
set 195
subsasgn 196
subsref 196
M-files
comments 19
contents 12
corresponding to functions 204
creating
in MATLAB directory 14
in MATLAB directory tree 14
quick start 11
creating with text editor 13
dispatching priority 20
input
keyboard 77
obtaining interactively 77
kinds 11
naming 10
operating on structures 132
optimization 79
overview 12
pausing during execution 77
primary function 51
subfunction 51
superseding existing names 52
Microsoft Windows
MATLAB use of system resources 85
mislocked 28
mlock 28
multidimensional arrays 104
applying functions 116
element-by-element functions 116
matrix functions 117
vector functions 116
cell arrays 120
computations on 116
creating 106
at the command line 106
with functions 108
with the cat function 109
extending 107
format 110
indexing 111
avoiding ambiguity 111
with the colon operator 111
number of dimensions 110
organizing data 118
permuting dimensions 114
removing singleton dimensions 113
reshaping 112
size of 110
storage 110
structure arrays 121
applying functions 122
subscripts 105
multiple conditions for switch 46
multiple inheritance 218
multiple output values 17
munlock 28

names
function 19
structure fields 127
superseding 52
variable 27
NaN 29
nargin 22
nargout 22
ndgrid 104
ndims 104, 110 <1> <2>
nesting
cell arrays 150
for loops 48
functions 83
if statements 44
structures 138
newlines in string arrays 98
not equal to operator 36
NOT operator
rules for evaluating 38
Not-a-Number 29
now 76
number of arguments 22
numbers
changing to strings 101
date 71
time 71

object-oriented programming 184
converter functions 207
features of 185
inheritance
multiple 218
simple 217
overloading 203, 205 <1> <2>
subscripting 196
overview 185
See also classes and objects
objects
accessing data in 195
as indices into objects 201
creating 186
invoking methods on 187
loading 242
overview 185
precedence 247
saving 242
offsets for indexing 61
ones 56, 108 <1> <2>
online help 18
operator precedence 40
overriding 41
operators 34
& 37
| 37
~ 37
applying to cell arrays 148
applying to structure fields 131
arithmetic 34
colon 34, 107, 111, 117, 145 <1> <2> <3> <4> <5>
complex conjugate 34
deletion 57
equal to 36
greater than 36
greater than or equal to 36
less than 36
less than or equal to 36
logical 37
matrix power 35
not equal to 36
overloading 185, 203 <1> <2>
power 34
relational 36
subtraction 34
table of 204
unary minus 34
optimization 79
preallocation, array 81
vectorization 79
organizing data
cell arrays 148
multidimensional arrays 118
structure arrays 133
Out of Memory message 86
overloading 196
arithmetic operators 211
functions 203, 205, 213 <1> <2> <3>
loadobj 243
operators 185
pie3 239
saveobj 243

pack 82
page subscripts 105
parentheses
for input arguments 17
overriding operator precedence with 41
passing arguments
by reference 22
by value 22
path
adding directories to 189
pausing during M-file execution 77
pcode 21
PCs and MATLAB use of system resources 85
percent sign (comments) 19
permute 104, 114 <1> <2>
permuting array dimensions 114
inverse 115
persistent variables 28
pi 29
pie3 function overloaded 239
plane organization for structures 135
polar 15
polynomials
example class 206
power operator 34
preallocation 81
cell array 81, 144 <1> <2>
structure array 82
precedence
object 247
operator 40
overriding 41
primary function 51
private directories 53
private directory
in dispatching priority 20
private functions 53
function handles to 158, 174 <1> <2>
precedence of 251
private methods 188
programming, object-oriented 184
programs
running external 78
pseudocode 21

quit 82

randn 108
realmax 29
realmin 29
reducing memory fragmentation 82
reference, subscripted 196
relational operators
empty arrays 37
strings 97
removing
cells from cell array 145
fields from structure arrays 131
singleton dimensions 113
replacing substring within string 99
repmap 108
reshape 112, 146 <1> <2>
reshaping
cell arrays 146
multidimensional arrays 112
return 50
rmfield 131

save 82
function handles 179
saveobj example 244
saving
objects 242
scalar
and relational operators 97
expansion 35
string 97
scripts 11, 15 <1> <2>
characteristics 11
example 15
executing 15
search path 20
M-files on 51
set method 195
setfield 130
shell escape functions 78
shiftdim 104
simple inheritance 217
sin 15, 116 <1> <2>
single data type 31
single-precision matrix 30
size
structure arrays 131
structure fields 131
size 110, 131 <1> <2>
smallest value system can represent 29
sparse data type 32
sparse matrix 30
special values 29
square brackets
for output arguments 17
squeeze 104, 113, 117 <1> <2> <3>
statements
conditional 22
storage
array 59
str2func
description 176
example 177
strcmp 96
strings
See also character arrays
struct data type 32
structs 126, 127, 138 <1> <2> <3>
structure arrays 125
accessing data 128, 130 <1> <2>
adding fields 131
applying functions to 131
building 126
using structs 127
data organization 133
deleting fields 131
element-by-element organization 136
expanding 126, 127 <1> <2>
fields 125
assigning data to 126
assigning using setfield 130
indexing
nested structures 139
within fields 129
multidimensional 121
applying functions 122
nesting 138
obtaining field names 127
organizing data 133
example 137
overview 125
plane organization 135
preallocation 82
size 131
subarrays,accessing 129
subscripting 126
used with classes 190
within cell arrays 152
writing M-files for 132
example 133
structures
See also structure arrays
subassign 199
subfunctions 51
accessing 51
creating 51
debugging 52
definition line 51
function handles to 158, 173 <1> <2>
in dispatching priority 20
precedence of 251
subref 196
subsasgn 196
subscripted assignment 199
subscripting 54
how MATLAB calculates indices 61
multidimensional arrays 105
overloading 196
page 105
structure arrays 126
with logical expression 40
with the find function 40
subsref method 196
substring within a string 99
subtraction operator 34
sum 116
superiorto function 248
superseding existing M-files names 52
switch 45
case groupings 45
example 46
multiple conditions 46

tabs in string arrays 98
time
numbers 71
token in string 99
tolerance 29
transpose 115
trigonometric functions 15, 116 <1> <2>

uint data type 32
unary minus operator 34
user classes, designing 191
user input
obtaining interactively 77
UserObject data type 32

value
largest system can represent 29
varargin 25, 148 <1> <2>
in argument list 26
unpacking contents 25
varargout 25
in argument list 26
packing contents 25
variables
deleting
and memory use 83
dispatching priority 20
global 27
rules for use 28
local 27
memory usage 84
naming 27
persistent 28
replacing list with a cell array 146
storage in memory 83
vector
of dates 73
preallocation 81
vectorization 79
example 79
replacing for
vectorization 43
version 29
version, obtaining 29
visualizing
cell array 142

warnings 67
displaying 68
which used with methods 252
while 47
empty arrays 47
example 47
syntax 47
white space
finding in string 98
whos 110
interpreting memory use 83
Windows
MATLAB use of system resources 85
workspace
context 22
of individual functions 22

xor 39

zeros 108

Querying Which Method MATLAB Will Call