You are on page 1of 10

Al-Nahrian University

Department of Computer Engineering

Digital Signal Processing Lab


Experiment No. 5
Operations of Signal

Name: Haval Amanj Hussen.

Class: Stage Three.

Lab supervisor: M.Se Esraa Adnan Hadi

Date of submitting the report: 5/11/2022


Experiment No.5
Operations of Signal

1- Objectives:

1. Understanding time properties of signals.

2. Carrying out different transformation on signals such as multiplication, shifting,


scaling, addition, subtraction, etc in MATLAB.
2- Theory:-

There are some important properties of signal such as time reversal,


amplitude-scaling, time-scaling and time-shifting.

2.1 Time Reversal:


Until now, we have assumed our independent variable representing the signal
to be positive. Why should this be the case? Can't it be negative? It can be
negative. In fact, one can make it negative just by multiplying it by -1. This causes
the original signal to flip along its y-axis. That is, it results in the reflection of the
signal along its vertical axis of reference. As a result, the operation is aptly known
as the time reversal or time reflection of the signal. For example, let's consider our
input signal to be x[n], shown in figure(a). The effect of substituting –n in the place
of n results in the signal y[n] as shown in figure (b).
Figure (1): Time Reversal
Here you can observe that the value of x[n] at the time instant n = -2 is -1.
This is equal to the value of y[n] at n = 2. Likewise, x[-0.5] = y[0.5] = -1, x[1] = y[-
1] = 1, and x[4] = y[-4] = 4 (as indicated by the green dotted-dashed-line arrows).
This indicates that the graph of y[n] is nothing but the original signal x[n] reflected
along the vertical axis (shown as a dotted orange line in the figure).This applies to
both continuous- and discrete-time signals.
2.2 Time scaling:
Time scaling compresses or dilates a signal by multiplying the time variable
by some quantity. If that quantity is greater than one, the signal becomes narrower
and the operation is called compression. If that quantity is less than one, the signal
becomes wider and the operation is called dilation. Figures below show the signal
x(t), compression of signal and dilation of signal respectively.
Figure (2): Time Scaling.
2.3 Time Shifting:
In signals and system amplitude scaling, time shifting and time scaling are
some important properties. If a continuous time signal is defined as x(t) = s(t - t1).
Then we can say that x(t) is the time shifted version of s(t). Consider a simple
signal s(t) for 0 < t < 1 Now shifting the function by time t1 = 2 sec.
x(t) = s (t-2)=t-2 for 0 < (t - 2) <1=t-2 for 2 < t <3

Figure (3): Time Shifting.


2.3.1 Time-Delayed Signals:
Suppose that we want to move this signal right by three units (i.e., we want a
new signal whose amplitudes are the same but are shifted right three times). This
means that we desire our output signal y[n] to span from n = 0 to n = 6. Such a
signal is shown as Figure (b) and can be mathematically written as y[n] = x[n-3].
This kind of signal is referred to as time-delayed because we have made the signal
arrive three units late.
2.3.2 Time-Advanced Signals:
On the other hand, let's say that we want the same signal to arrive early.
Consider a case where we want our output signal to be advanced by, say, two units.
This objective can be accomplished by shifting the signal to the left by two time
units, i.e., y[n] = x[n+2].

The corresponding input and output signals are shown in Figure (a) and (b),
respectively. Our output signal has the same values as the original signal but spans
from n = -5 to n = 1 instead of n = -3 to n = 3. The signal shown in Figure (b) is
aptly referred to as a time-advanced signal

Figure (4): Original signal and its time-advanced version


For both of the above examples, note that the time-shifting operation performed
over the signals affects not the amplitudes themselves but rather the amplitudes
with respect to the time axis. We have used discrete-time signals in these
examples, but the same applies to continuous-time signals.

2.4 Amplitude scaling:


Consider a signal x(t) which is multiplying by a constant 'A' and this can be
indicated by a notation x(t) → Ax(t). For any arbitrary 't', this multiplies the signal
value x(t) by a constant 'A'. Thus, x(t) → Ax(t) multiplies x(t) at every value of 't'
by a constant 'A'. This is called Amplitude-scaling. If the amplitude-scaling factor
is negative, then it flips the signal with the t-axis as the rotation axis of the flip. If
the scaling factor is -1, then only the signal will be flip. This is shown in the
figures given below:

Figure (5): Amplitude scaling.


3- Procedure:
1) For the following sequence x(n)=[0 0 1 2 3 4 5 4 3], write a MATLAB program
to find x(-n), then plot each of the input and output signals in the same figure?

Program:

clc
close all;
n=0:1:8;
m=[0,0,1,2,3,4,5,4,3];

subplot(2,1,1);
stem(n,m);

axis([-10 15 -7 7])
grid on

subplot(2,1,2)
stem(-n,m)

axis([-10 15 -7 7])
grid on

2) For the following sequence x(n)=[2 2 2 2 0 1 1 1 1], write a MATLAB program


to find x(-n)?
Program:
clc
close all;
n=-2:1:6;
m=[2 2 2 2 0 1 1 1 1];
subplot(2,1,1);
stem(n,m);
axis([-10 15 -7 7])
grid on
subplot(2,1,2)
stem(-n,m)
axis([-10 15 -7 7])
grid on
3) For the following continuous- time signal y=sin (t), write a program in
MATLAB simulation to find the time scaling where, k=2 and k=0.5 for t=0 to 4
pi?
Program:
clc
close all;
n=0:4*pi;
amp=sin(n);

subplot(3,1,1);
stem(n,amp);

axis([-10 15 -2 2])
grid on

subplot(3,1,2)
stem(n*2,amp)

axis([-10 15 -2 2])
grid on

subplot(3,1,3)
stem(n*0.5,amp)

axis([-10 15 -2 2])
grid on
4) For the following continuous- time signal y=sin (2 pi t), write a program in
MATLAB simulation to find the time shifting where, k=+2 and k=-2 for t=0 to
4?
Program:
clc
close all;
n=0:4*pi;
amp=sin(n);
x1=n+2;
x2=n-2;
subplot(3,1,1);
stem(n,amp);
axis([-10 15 -2 2])
grid on
subplot(3,1,2)
stem(x1,amp)
axis([-10 15 -2 2])
grid on
subplot(3,1,3)
stem(x2,amp)
axis([-10 15 -2 2])
grid on

4- Discussion

Using MATLAB programs, plot the output of the following operations:

1) Add two signal X & Y where X= [0 1 6 5] and Y will be user defined?


Program:
clc
close all;
clear all;
t=0:3;
x= [0 1 6 5];
%make sure write the input in this exprition
%example of that : [1 2 3 4] and they should be 4 num in this code
y= input('inter array of singlas:');
subplot(2,1,1)
stem(t,x);
axis([-10 15 -7 7])
grid on

subplot(2,1,2)
stem(t,y);
axis([-10 15 -7 7])
grid on
2) Multiply signal X with signal Y given that; X= [5 1 0 6] and Y= [-1 0 0.5 3] ?
Program:
clc
close all;
clear all;
t=0:3;
x= [5 1 0 6];
y= [-1 0 0.5 3] ;
multi=x.*y;
disp(multi);
subplot(3,1,1)
stem(t,x);
axis([-10 15 -7 7])
grid on

subplot(3,1,2)
stem(t,y);
axis([-10 15 -7 7])
grid on

subplot(3,1,3)
stem(t,multi);
axis([-10 15 -7 7])
grid on

3) For the following sequence x(n)=[0 0 1 2 3 4 5 4 3], write a program in


MATLAB to find x(2*n) and x(n/2)?
clc
close all;
clear all;
t=0:8;
x=[0 0 1 2 3 4 5 4 3];
xmulti= x*2 ;
xdiv=x/2;
subplot(3,1,1)
stem(t,x);
axis([-10 15 -7 7])
grid on

subplot(3,1,2)
stem(t,xmulti);
axis([-10 15 -7 7])
grid on

subplot(3,1,3)
stem(t,xdiv);
axis([-10 15 -7 7])
grid on

You might also like