Experiment No.3: N 0. Folding Is Also Known As The Reflection of The Signal
Experiment No.3: N 0. Folding Is Also Known As The Reflection of The Signal
3
Aim: Write MATLAB Codes for generating and plotting
various combinations of the two signals and perform time
scaling, time shifting, time reversal and multiple
Transformations.
Theory:
When a signal is processed, the signal undergoes many
manipulations involving the independent variable and the
dependent variable. Some of these manipulations include:
• Shifting the signal in the time domain.
• Folding the signal
• Scaling in the time-domain
A brief introduction of these manipulations is given below.
Shifting
In the case of discrete-time signals, the independent variable
is the time, n. A signal x(n)may be shifted in time, i.e. the
signal can be either advanced in the time axis or delayedin the
time axis. The shifted signal is represented by x(n-k), where k
is an integer. If ‘k’ ispositive, the signal is delayed by k units
of time and if k is negative, the time shift results
in an advance of signal by k units of time.
Folding
This operation is done by replacing the independent variable n
by –n. This results infolding of the signal about the origin, i.e.
n=0. Folding is also known as the reflection of the signal
about the time origin n=0. Folding of a signal is done while
convoluting the signal with another.
Time scaling
This involves replacing the independent variable n by kn,
where k is an integer. Thisprocess is also called as down
sampling. If x(n) is the discrete-time signal obtained by
sampling the analog signal, x(t), then x(n) = x (nT), where T is
the sampling period. If time–scaling is done, then the time-
scaled signal, y[n]=x(kn)=x(knT). This implies that the
sampling rate is changed from 1/T to 1/kT.
Implementation:
Steps for converting continuous time signal to the discrete
time signal are as follows:
1). Assign the value of sampling time, T .
2). Vary the time integer ‘n’ between two integer points with
an increment of 1.
3). The discrete version can be obtained as: y(n) = y(nT).
-4, n<-6
x[n] = n, -6<=n<3
2/n, 3<=n
(a) n=-20:1:20;
x=-4*(-n<(-6))+(-n.*((-6)<=-n & -n<3))+(2./(-n)).*(-
n>=3);
subplot(2,2,1),stem(n,x)
title('week 3 q2')
(b) n=-20:1:20;
x=-4*((3-n)<(-6))+((3-n).*((-6)<=(3-n) & (3- n)<3))
+(2./(3-n)).*((3-n)>=3);
subplot(2,2,2),stem(n,x)
title('week 3 q2')
(c) n=-20:1:20;
x=-4*((2.*n)<(-6))+((2.*n).*((-6)<=(2.*n) &
(2.*n)<3))+(2./(2.*n)).*((2.*n)>=3);
subplot(2,2,3),stem(n,x)
title('week 3 q2')
(d) n=-20:1:20;
x=-4*((n./2)<(-6))+((n./2).*((-6)<=(n./2) & (n./2)<3))
+(2./(n./2)).*((n./2)>=3);
subplot(2,2,4),stem(n,x)
title('week 3 q2')
3.Generate x (t) & sketch each of the following signals
derived from x (t) :
i) x(3t)
ii) x(3t + 2)
iii) x(2 − t)
i) n=-5:0.1:5;
x=0.*(n<-1)+(n+1).*(-1<=n & n<0)+(1-n).*(0<=n &
n<1)+0.*(n>=1);
subplot(2,2,1),plot(n,x)
ii) n=-5:0.1:5;
x1=0.*((3.*n)<-1)+((3.*n)+1).*(-1<=(3.*n) &
(3.*n)<0)+(1-(3.*n)).*(0<=(3.*n) &
(3.*n)<1)+0.*((3.*n)>=1);
subplot(2,2,2),plot(n,x1)
iii) n=-5:0.1:5;
x2=0.*((3.*n+2)<-1)+((3.*n+2)+1).*(-1<=(3.*n+2) &
(3.*n+2)<0)+(1-(3.*n+2)).*(0<=(3.*n+2) &
(3.*n+2)<1)+0.*((3.*n+2)>=1);
subplot(2,2,3),plot(n,x2)
iv) n=-5:0.1:5;
x3=0.*((2-n)<-1)+((2-n)+1).*(-1<=(2-n) & (2-
n)<0)+(1-(2-n)).*(0<=(2-n) & (2-n)<1)+0.*((2-n)>=1);
subplot(2,2,4),plot(n,x3)
Post lab Question:
Q1. Generate this signal:
t=-2:0.01:8;
x1=-2.*(1*(t==-1)+0*(t~=-1))+(2*t).*(-1<t & t<1)+2.*(1<=t
& t<2)+3.*(1*(t==2)+0*(t~=2))-2.*(1*(t==2)+0*(t~=2))+(-
t+5).*(2<=t & t<4)+1.*(4<=t & t<5)+(-t+6).*(5<=t &
t<7)+1.*(1*(t==7)+0*(t~=7));
plot(t,x1)
title('week3 home1')
a) x [2n]
b) x [3n – 1]
c) x [3 - n]
a) n=-10:1:10;
x1=0.*(1*(n==-4))+(0*(n~=-4))+(-1).*(1*(n==-3))
+(0*(n~=-3))+0.*(1*(n==-2))+(0*(n~=-2))+2.*(1*(n==-
1))+(0*(n~=-1))+1.*(1*(n==0))+(0*(n~=0))
+1.*(1*(n==1))+(0*(n~=1))+0.*(1*(n==2))+(0*(n~=2));
subplot(2,2,1),stem(n,x1)
title('week3 home2')
b) n=-10:1:10;
x2=0.*(1*(2*n==-4))+(0*(2*n~=-4))+(-1).*(1*(2*n==-
3))+(0*(2*n~=-3))+0.*(1*(2*n==-2))+(0*(2*n~=-2))
+2.*(1*(2*n==-1))+(0*(2*n~=-1))+1.*(1*(2*n==0))
+(0*(2*n~=0))+1.*(1*(2*n==1))+(0*(2*n~=1))
+0.*(1*(2*n==2))+(0*(2*n~=2));
subplot(2,2,2),stem(n,x2)
title('week3 home2a')
c) n=-10:1:10;
x3=0.*(1*((3*n-1)==-4))+(0*((3*n-1)~=-4))+(-
1).*(1*((3*n-1)==-3))+(0*((3*n-1)~=-3))+0.*(1*((3*n-
1)==-2))+(0*((3*n-1)~=-2))+2.*(1*((3*n-1)==-1))
+(0*((3*n-1)~=-1))+1.*(1*((3*n-1)==0))+(0*((3*n-
1)~=0))+1.*(1*((3*n-1)==1))+(0*((3*n-1)~=1))
+0.*(1*((3*n-1)==2))+(0*((3*n-1)~=2));
subplot(2,2,3),stem(n,x3)
title('week3 home2b')
d) n=-10:1:10;
x4=0.*(1*((3-n)==-4))+(0*((3-n)~=-4))+(-1).*(1*((3-
n)==-3))+(0*((3-n)~=-3))+0.*(1*((3-n)==-2))+(0*((3-
n)~=-2))+2.*(1*((3-n)==-1))+(0*((3-n)~=-1))+1.*(1*((3-
n)==0))+(0*((3-n)~=0))+1.*(1*((3-n)==1))+(0*((3-
n)~=1))+0.*(1*((3-n)==2))+(0*((3-n)~=2));
subplot(2,2,4),stem(n,x4)
title('week3 home2c')
Q3. Plot the function defined by
0 t<2
-4-2t -2<t<0
x(t) = -4+3t 0<t<4
16-2t 4<t<8
2 8<t
t =-20:0.01:20;
x1=0.*(t<-2)+(-4-2*t).*(-2<t & t<0)+(-4+3*t).*(0<t &
t<4)+(16-2*t).*(4<t & t<8)+2.*(t>8);
subplot(2,2,1),plot(t,x1)
title('week3 home3')