Professional Documents
Culture Documents
Lab 3 - Operations On Signals
Lab 3 - Operations On Signals
BASIC OPERATIONS
TIME SHIFT
A simple and very important example of transforming the independent variable of a signal
is a time shift. A time shift discrete time in it we have two signals𝒙[𝒏] and 𝒙[𝒏 − 𝒏𝒐]that
is identical in shape, but are displaced or shifted relative to each other. Eq.1 shows a time
shifted discrete-time signal.
TIME REVERSAL
𝒙[−𝒏] (3-2)
A Time reversal signal x[−n] of x[n]is obtained by reflection about n=0 (i.e by reversing
the signal).
TIME SCALING
𝒙[𝜶𝒏] (3-3)
If we represent three signals x[n] , x[2n], x[3n] , that are related by linear scale changes
in the independent variable. If we think of the example x[n] as tape recording, then x[2n]
Lab :03 Operations on Signals
is that recording played at twice the speed, and x[n/2] is the recording played at half-
speed.
PERIODIC SEQUENCE
A sequence x[n] is periodic if
The smallest integer that satisfies the above relation is called the fundamental period.
LAB TASK
Signal addition is implemented in MATLAB by using the arithmetic operator “+”. However, the
length of x1(n) and x2(n) must be same. If sequences are of unequal length, or if the sample
positions are different for equal length sequences; then we can’t directly use the operator “+”.
Implement below code for adding sequences of unequal length:
end
Generate x1 and x2 given below
𝟏; 𝟏 ≤ 𝒏𝟏 ≤ 𝟗
𝒙𝟏 [𝒏𝟏] = {
𝟎; 𝒐𝒕𝒉𝒆𝒓𝒘𝒊𝒔𝒆
𝟏; 𝟑 ≤ 𝒏𝟐 ≤ 𝟏𝟎
𝒙𝟐 [𝒏𝟐] = {
𝟎; 𝒐𝒕𝒉𝒆𝒓𝒘𝒊𝒔𝒆
Add x1[n] and x2[n] using function “sigadd”.
Signal multiplication is implemented in MATLAB by using the array operator “.*”. However, the
length of x1(n) and x2(n) must be same. If sequences are of unequal length, or if the sample
positions are different for equal length sequences; then we can’t directly use the operator “.*”.
Implement below code for multiplying sequences of unequal length:
%
n=min(min(n1),min(n2)):max(max(n1), max(n2)); % duration of y(n)
y1=zeros(1,length(n)); y2=y1; % initiallization
y1(find((n>=min(n1))&(n<=max(n1))==1))=x1;
y2(find((n>=min(n2))&(n<=max(n2))==1))=x2;
y=y1.*y2;
end
Multiply both the signals defined in task 1 x1 [n] and x2 [n] using the function “sigmult”.
TASK 3: SCALING
Scale both the signals defined in task 1 x1 [n] and x2 [n] such that we get 2x1 [n] ,5x2 [n].
Show the results to the instructor.
TASK 4: SHIFTING
In this each sample of “x(n)” is shifted by an amount “k” to obtain a shifted sequence “y(n)”
TASK 5: FOLDING
In this operation each sample of “x(n)” is flipped around n=0, to obtain a folded sequence “y(n)”
In MATLAB this operation is implemented by “fliplr(x)” function for sample values and by
“flipper(n)” function for sample positions as shown in the “sigfold” function.
Fold the signal obtained in the task 1 and show to the instructor.
This operation differs from signal addition operation. It adds all sample values of x(n) between
x(n1) and x(n2).
𝐧𝟐
(3-12)
∑ 𝐱(𝐧) = 𝐱(𝐧𝟏) + ⋯ + 𝐱(𝐧𝟐)
𝐧=𝐧𝟏
ss = sum(x(n1:n2));
What result you have concluded from the functions “sigadd” and “sum”
This operation also differs from the signal multiplication operation. It multiplies all sample values
of x(n) between n1 and n2.
𝐧𝟐
(3-13)
∏ 𝐱(𝐧) = 𝐱(𝐧𝟏 ) × … × 𝐱(𝐧𝟐 )
𝐧𝟏
sp = prod(x(n1:n2));
Split the signal X1[n] obtained in the task 1 into its even and odd parts and show to the
instructor.
Use stem function and plot ye , yo , and compare it to the 𝐲[𝐧]
Lab :03 Operations on Signals
LAB ASSIGNMENT
P.1
Generate
𝒙(𝒏) = 𝒆(−𝒋𝟒𝝅𝒏) , 𝟎 ≤ 𝒏 ≤ 𝟏𝟎
P.2
𝒙(𝒏) = 𝒆(−𝟒𝝅𝒏) , 𝟎 ≤ 𝒏 ≤ 𝟏𝟎
Plot its even and odd part, and show the graph in which all x(n), xe(n) and xo(n) are given using
subplot command.