Experiment (4) Mathematical Operations Using MATLAB: Signal and Systems Laboratory
Experiment (4) Mathematical Operations Using MATLAB: Signal and Systems Laboratory
2nd Class
Ninevah University
SIGNALS AND SYSTEMS LABORATORY
Collage: Electronics Engineering
Year: 2021-2022
Dept: Systems and Control Eng.
Experiment [4]
Mathematical Operations using MATLAB
Introduction:
MATLAB has three different types of arithmetic operations: column oriented operations,
array oriented operations and matrix arithmetic operations.
1) Column Oriented Operation
This type of operation deal with each column, for example
Sum(a), max(a), min(a)
2) Array Arithmetic Operation
Array arithmetic operations are carried out element by element, and can be used with
multidimensional arrays. Arithmetic operations are (addition, subtraction, multiplication,
division and power).
Addition (A+B): Adds A and B. Both of A and B must have the same size, unless one of
them is a scalar. A scalar can be added to a matrix of any size.
Subtraction (A-B): Subtracts B from A. Both of A and B must have the same size, unless
one is a scalar. A scalar canbe subtracted from a matrix of any size.
.* Array multiplication (A.*B): Is element by element product of the arrays A and B. A
and B must have the same size, unless one of them is a scalar.
./ Array right division(A./B): Is the matrix with elements A(i,j)/B(i,j). A and B must have
the same size, unless one of them is a scalar.
.\ Array left division (A.\B): Is the matrix with elements A(i,j)\B(i,j). A and B must have
the same size, unless one of them is a scalar.
.^ Array power (A.^B): Is the matrix with elements A(i,j) to the B(i,j) power. A and B
must have the same size, unless one of them is a scalar.
.' Array transpose (A.' ): Is the array transpose of A. For complex matrices, this does not
involve conjugation.
1
SIGNAL AND SYSTEMS LABORATORY
3) Matrix operations
Matrix arithmetic operationsare defined by the rules of linear algebra, the matrix and
array operations are same for addition and subtraction.
Matrix multiplication (A*B): Is the linear algebraic product of the matrices A and B.
More precisely
𝑛
𝑐(𝑖, 𝑗) = ∑ 𝐴(𝑖, 𝑘)𝐵(𝑘, 𝑗)
𝑘−1
For nonscalar A and B, the number of columns of A must equal the number of rows of B.
A scalar can multiply a matrix of any size.
Slash or matrix right division(A/B): Is roughly the same as: B*inv(A), more precisely:
B/A=(A'/B')'
Backslash or matrix right division(A/B): If A is a square matrix B\A is roughly the same
as: inv(B)*A. more precisely: B/A=(A'/B')'
^ Matrix power(X^p): Is X to the power p, if p is a scalar. If p is an integer, the power is
computed by repeated squaring.If the integer is negative, X is inverted first.
General Mathematical Functions:
MATLAB offers many predefined mathematical functions for technical computing which
contains a large set of mathematical functions. There is a long list of mathematical
functions that are built into MATLAB. These functions are called built-ins. Many
standard mathematical functions, such as sin(x), cos(x), tan(x), ln(x) are evaluated by the
functions sin, cos, tan, exp, and log respectively in MATLAB. Table 1 lists some
commonly used functions, where variables x and y can be numbers, vectors, or matrices.
Table 1: Elementary functions
cos(x) Cosine abs(x) Absolute value
Sin(x) Sine sign(x) Signum function
tan(x) Tangent max(x) Maximum value
acos(x) Arc cosine min(x) Minimum value
asin(x) Arc sine ceil(x) Round towards +∞
atan(x) Arc tangent floor(x) Round towards -∞
exp(x) Exponential round(x) Round to nearest integer
sqrt(x) Square root rem(x) Remainder after division
2
SIGNAL AND SYSTEMS LABORATORY
3
SIGNAL AND SYSTEMS LABORATORY
4
SIGNAL AND SYSTEMS LABORATORY
5
SIGNAL AND SYSTEMS LABORATORY
6
SIGNAL AND SYSTEMS LABORATORY
Experiment:
1- What are the results of the following instructions:
>> a=[5 2 3 5 8];
>> b=[9 2 5 0 8];
>> a'
>>a-1
>>a.*b
>> a*b
>>a.^3
3-Find the matrix a - bc2 + 2d' when the matrices a, b, c and d are:
4-For the matrix x=[3+4i 1-i] , find the result of the following:
conj(x)
imag(x)
real(x)
abs(x)