3-Arrays and Matrix Definition and Operations 9-3-2022
3-Arrays and Matrix Definition and Operations 9-3-2022
Operations
Dr. Emile M. Al-Mayah
Biochemical Engineering Department
Al-Khwarizmi College of Engineering
University of Baghdad
ARRAYS AND MATRIX
DEFINITION & OPERATION
OBJECTIVES
Array:
Technically an array is an orderly grouping of
information.
Matrix:
The technical definition of a matrix is a two-dimensional
numeric array used in linear algebra.
A matrix is composed of rows (row vectors) and
columns (column vectors).
THE DIFFERENCE BETWEEN AN ARRAY
AND A MATRIX
• Arrays:
Arrays can contain numeric information, but they can also contain
character data, symbolic data etc.
• Matrices:
Not even all numeric arrays can precisely be called matrices-
only those upon which you intend to perform linear
transformations meet the strict definition of a matrix.
Matrix algebra is used extensively in engineering applications.
Matrix algebra is different from the array calculations we have
performed thus far.
MATRIX OPERATIONS AND FUNCTIONS
Matrix determinant
det(A) – determinant of square matrix A
For example, the determinant of a 2 × 2 (square) matrix, is
defined as:
det(A)=a11×a22-a12×a21
For A=[3, 7; 5,9]
det(A)=3×9-7×5=27-35=-8
In MATLAB,
>> Adet=det(A)
Adet=
-8
ARRAYS OPERATIONS AND FUNCTIONS
For a vector v
mean(v) – mean (average)
max(v) – maximum value, optionally with index of maximum
min(v) – minimum value, optionally with index of minimum
sum(v) – sum
sort(v) – elements sorted into ascending order
median(v) – median
std(v) – standard deviation
dot(v,w) – dot (inner product); v, w both vectors of same
size but any dimension
cross(v,w) – cross product; v, w must both have three
elements but any dimension
roots (v)– finding the roots of polynomial equation.
ARRAYS OPERATIONS AND FUNCTIONS
Example1,
Find the roots of the polynomial
(x − 1)(x + 2)(x − 3) = (x − 1)(x2 − x − 6) = x3 − 2x2 − 5x + 6.
Solution
>> u=[1 -2 -5 6]
>> Theroots=roots(u)
Theroots=
-2.0000
3.0000
1.0000
C.W.1
Problem 1/
Solve (i.e., find the roots of) the following
polynomials using MATLAB built-in roots function for
the vectors of coefficients: ax4-bx3+cx2-dx+e=0