0% found this document useful (0 votes)
28 views7 pages

Experiment (4) Mathematical Operations Using MATLAB: Signal and Systems Laboratory

1) MATLAB can perform three types of mathematical operations on arrays: column operations, element-wise array operations, and matrix operations. 2) Common array operations in MATLAB include addition, subtraction, multiplication, division, and powers. Matrix operations follow the rules of linear algebra. 3) MATLAB can solve systems of linear equations using the matrix inverse or backslash operator. It can also perform basic mathematical functions on arrays and matrices like trigonometric, exponential, logarithmic, and statistical operations.

Uploaded by

Naoo 0099
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)
28 views7 pages

Experiment (4) Mathematical Operations Using MATLAB: Signal and Systems Laboratory

1) MATLAB can perform three types of mathematical operations on arrays: column operations, element-wise array operations, and matrix operations. 2) Common array operations in MATLAB include addition, subtraction, multiplication, division, and powers. Matrix operations follow the rules of linear algebra. 3) MATLAB can solve systems of linear equations using the matrix inverse or backslash operator. It can also perform basic mathematical functions on arrays and matrices like trigonometric, exponential, logarithmic, and statistical operations.

Uploaded by

Naoo 0099
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/ 7

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

log(x)Natural logarithm angle(x) Phase angle


log10(x) Common logarithm conj(x) Complex conjugate

In addition to elementary functions, MATLAB includes a number of predefined constant


values. A list of most common values is given in table 2.
Table 2.2: Predefined constant values
pi The π number, π=3.14159…
i, j The imaginary unit i, √−1
inf The infinity, ∞
NaN not a number
For example:
>> a=5; x=2; y=8;
>>y=exp(-a) * sin(x)+10* sqrt(y)
y=
28.2904
>> log(142)
ans=
4.9558
>> log10(142)
ans=
2.1523

3
SIGNAL AND SYSTEMS LABORATORY

Matrix operations vs. array operations


Here are two vectors, and the results of various matrix and array operations on them.

4
SIGNAL AND SYSTEMS LABORATORY

Solving linear equations:


One of the problems encountered most frequently in scientific computation is the solution
of systems of simultaneous linear equations. With matrix notation, a system of
simultaneous linear equations is written: Ax = b
where there are as many equations as unknowns. A is a given square matrix of order n, b
is a given column vector of n components, and x is an unknown column vector of n
components.
In linear algebra we learn that the solution to Ax=b can be written as x=A-1 b where A-1is
the inverse of A. For example, consider the following system of linear equations:
x+2y+3z=1
4x+5y+6z=1
7x+8y =1

5
SIGNAL AND SYSTEMS LABORATORY

Using matrix notation, a system of simultaneous linear equations is written as:Ax=B ,


where:
1 2 3 1
𝐴 = [4 5 6] , 𝐵 = [1]
7 8 0 1
This equation can be solved for x using linear algebra. There are two ways to solve for x
using MATLAB:
1. The first way is to use the matrix inverse:
>> A=[ 1 2 3; 4 5 6; 7 8 0];
>> B=[ 1; 1 ; 1];
>> x=inv(A) *B
x=
-1
1
0
2. The second way is to use the backslash operation.The numerical algorithm behind
this operator is computationally efficient. This is numerically reliable way of solving
a system of linear equations by using a well-known process of Gaussian elimination:
>> A =[1 2 3; 4 5 6; 7 8 0];
>>B = [1; 1; 1];
>>x=A\B
x=
-1
1
0

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

2-What is the result of each the following command?


>>B=magic(4)
>>A=B(:,[1 3 2 4])
Delete the 3rd row

3-Find the matrix a - bc2 + 2d' when the matrices a, b, c and d are:

1.5 3.3 0.5 0.3


𝑎=[ 6 −4.5] 𝑏 = [−0.1 0.2 ]
−2.5 0.7 0.4 −0.3
1 2 3.1 1.4 −0.3
𝑐=[ ] 𝑑=[ ]
1 2 −0.5 1.6 0.1

4-For the matrix x=[3+4i 1-i] , find the result of the following:
conj(x)
imag(x)
real(x)
abs(x)

5- Try the three functions: round, floor and ceil on z, where:


z=[-3.6, -2.5, -1.4 , -1 , 0 , 1.4 , 2.5 , 3.6]

6- Given the following array:


A= [1 2 5 3 ; 1 5 3 0 ; 0 1 5 2 ; 0 6 4 7]
What is the command used to obtain the following array:
1 2 5 3 6 7 10 8
1 5 3 0 6 10 8 5
0 1 5 2 5 6 10 7
0 6 4 7 5 11 9 12
44 84 83 83 -2 -1 2 0
93 52 1 50 -2 2 0 -3
46 20 68 70 -3 -2 2 -1
41 67 37 42 -3 3 1 4
7

You might also like