Biomedical Engineering Reference
In-Depth Information
explicit or not. The real numbers have infinite precision,
which is something that is not available in computer
programs. Infinite precision would require infinite
memory; no computer has infinite memory.
Thus, the real numbers have to be represented by an
approximationdcalled the floating-point numbers.
Floating-point numbers require only a finite amount of
memory, but that means that there are real numbers that
cannot be represented using a floating-point representa-
tion. Floating-point representation has a large impact on
the accuracy and precision of the computation and is an
important topic to master before studying numerical
methods in detail.
A number written in a MATLAB script or function is
written using the conventional notation. MATLAB does
not distinguish between an integer, real, or complex
number; they are all stored as the same type of MATLAB
variable.
A number may have a leading plus or minus sign and
an optional decimal point. Numbers written in scien-
tific notation use the letter e to specify the exponent
(base 10). Imaginary numbers use either i or j as
a suffix to indicate an imaginary component. Some
examples of numbers
Solution
Recall that the inverse of a complex number aþbi can be
computed by
ða biÞ
ða þ biÞða biÞ
ða þ biÞ 1 ¼
The MATLAB function inv () computes the inverse of
the argument; the command:
>> inv(3 þ 5i)
ans ¼
0.0882 - 0.1471i
can be verified by the calculation using the formula
above, using the MATLAB function conj () to compute
the complex conjugate of the argument:
>> x ¼ 3 þ 5i;
>> conj (x)/(x*conj(x))
ans ¼
0.0882 - 0.1471i
2.1b.4.2 Arrays
that can be represented in
MATLAB are:
An array is a data structure for representing a collection
of objects that provides the ability to access each element
of the collection in the same amount of time. You do not
have to search all the way down a list, or through a matrix
in order to get to a desired element.
All arrays in MATLAB are stored as column vectors,
and each element can be accessed using only the single
index into the column vector. However, if there is more
than one index in the array reference, the location in the
column vector is computed using the formula:
Example 2.1b.7 Number representation in MATLAB.
Positive integer
3
Negative integer
45
Real number
0.00001
Scientific notation
2.71828e9
Complex number
3 þ 5i
Imaginary number
3.14159j
The amount of memory available to store each
number is limited; there is an upper and lower limit to
the real numbers that can be represented by the floating-
point numbers in MATLAB. The MATLAB functions
realmin and realmax return, respectively, the
smallest and the largest real numbers that can be repre-
sented in MATLAB. The function inf returns the rep-
resentation of infinity, and NaN returns a representation
for Not-a-Number, the result of an undefined operation
(such as 0.0/0.0) in MATLAB.
Complex numbers can be assigned directly to numeric
variables or they can be created from two real compo-
nents; the MATLAB command c ¼ complex (3,5)
creates a complex number c that is 3 þ 5i. The result of
the command c ¼ complex(3, 0) is a complex number
with an imaginary component 0 and is not a real number.
ðj 1 Þ * d þ i
to reference the array element Aði; jÞ, where d is the
length of one column. Subarrays of a multidimensional
array can be referenced in their entirety as well.
Example 2.1b.9 Indexing arrays in MATLAB.
Create a 5x5 matrix with elements Aði; jÞ¼ 1 2 i þ 3 j Þ .
Print the entire matrix, the first row and the second
column. Give two ways of displaying the element A (3,2).
Solution
Unlike many other programming languages, MATLAB
does not have a dimension statement or method for de-
claring the space allocated for a variable; MATLAB au-
tomatically allocates storage for matrices and other
arrays. For this problem, space for the matrix A is allo-
cated at the time the elements are created. Since a for-
mula is given for each element, the matrix can be created
in a script that also includes the statements to print the
Example 2.1.8 Complex numbers.
Compute the inverse of the complex number 3 þ 5i and
verify the result by hand calculation.
Search WWH ::




Custom Search