0% found this document useful (0 votes)
40 views10 pages

3-Arrays and Matrix Definition and Operations 9-3-2022

Here are the roots for the polynomials: a. roots([7 -3 3 -8 4]) b. roots([-7 3 -3 8 -4]) c. roots([7 3 -3 8 -4]) d. roots([7 3 3 -8 -4])

Uploaded by

Nour
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views10 pages

3-Arrays and Matrix Definition and Operations 9-3-2022

Here are the roots for the polynomials: a. roots([7 -3 3 -8 4]) b. roots([-7 3 -3 8 -4]) c. roots([7 3 -3 8 -4]) d. roots([7 3 3 -8 -4])

Uploaded by

Nour
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Arrays and Matrix

Operations
Dr. Emile M. Al-Mayah
Biochemical Engineering Department
Al-Khwarizmi College of Engineering
University of Baghdad
ARRAYS AND MATRIX
DEFINITION & OPERATION
OBJECTIVES

After this lecture the student will be able to;

• Perform the basic operations of matrix algebra.


• Solve simultaneous equations using MATLAB
matrix operations.
• Use some of MATLAB’s special matrices.
• Use some MATLAB matrix functions.
DEFINING ARRAY & MATRICES

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

A matrix can be entered in MATLAB in any of the


following ways:
(SEE THE WORKSPACE)
1. Using the carriage return key:
>> A=[1 2 3 4 5 6 7 8 9];
2. Using semicolons to indicate
the next line:
>> B=[3 4 5; 6 7 8; 9 10 11];

3. Using the colon (range) notation with semicolon:


>> C=[2:4; 5:7; 8:10];
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

a. 7x4 - 3x3 + 3x2 - 8x + 4 =0


b. -7x4 + 3bx3 - 3x2 + 8x – 4 =0
c. 7x4 + 3x3 - 3x2 + 8x – 4 =0
d. 7x4 + 3x3 + 3x2 - 8x – 4 =0

You might also like