Environmental Engineering Reference
In-Depth Information
Table 2.1 Defining table for
logical operators
or
a
Input parameter
and
not
xor
A
B
A & B
A | B
~A
xor(A,B)
0
0
0
0
1
0
0
1
0
1
1
1
1
0
0
1
0
1
1
1
1
1
0
0
a
The
|
symbol is reached by Alt-Strg-
>
It is also possible to check the type or any other characteristic of a variable. For
that purpose there are several
is...
keywords (which have at least one variable as
formal parameter):
is
oat
checks if a variable is a float, i.e. a single or double
islogical
checks if a variable is a logical
isscalar
checks if variable is a scalar
isvector
checks if variable is a vector
is
nite
checks if variable is finite
isinf
checks if variable is infinite
isnan
checks if variable is not a number
isnan
checks if variable is not a number
isempty
checks whether an array is empty
isnan
checks if variable is not a number
Look for
is*
in the help system (see Chap. 1.5) to obtain a complete list of all
such commands.
The
if
,
else
and
end
keywords are reserved and should not be used by the
MATLAB
user as function or variable names. The
if
,
else
and
end
keywords are
reserved and should not be used by the MATLAB
®
user as function or variable
names. An
if
without
else
is just a condition. Using the
if
-
else
construction, one
has the option to bifurcate into one of two branches. A bifurcation into several
branches can be realized by using nested if-else commands:
®