Professional Documents
Culture Documents
2
AIM : Plotting Elementary continuous time signals, Elementary discrete
time signals, Generate rectangular, sinc and triangle function.
APPARATUS/RESOURCE REQUIRED : Matlab Software
THEORY : A continuous -time signal x(t) is a function of an independent
variable t, that is time. A continuous -time signal x(t) is a mathematically
continuous function, and is defined continuously in the time domain.
A discrete-time signal y(n) is a function of an independent variable n, that is an integer. It is
important to note that a discrete-time signal is not defined at instants between two successive
samples. Also it is incorrect to think that y(n) is not defined for non-integer
values of n. y(n) can be obtained from sampling the continuous
signal y(t), then y(n) =y(nT), where T is the sampling period (i.e. the time between successive
samples).
IN LAB EXERCISE:
Q1. Plot the following continuous-time functions over the specified intervals.
Write single
script files for all CT signals with name CTsignals_GroupNo. X.m. Use the plot and
figure command, and be sure to label the time axes.
CODE:
t=-1:.01:1;
a=0.*(t>0)+0.*(t<0)+1.*(t==0);
plot(t,a);
xlabel('time')
OUTPUT:
1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
time
CODE:
t=-2:.01:2;
u=(1.*(t>0)+0.*(t<0))
plot(t,u);
xlabel('time(t)')
OUTPUT:
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
time(t)
OUTPUT:
-0.5
-1
-1.5
-2
-2.5
-3
-3.5
-4
-4.5
-5
-2 -1 0 1 2 3 4 5
time(t)
CODE:
t=-1:.01:1;
f=200;
y=3*sin(2*pi*f*t);
plot(t,y);
xlabel('time(t)')
OUTPUT:
(e) Exponential function, x5(t) = e-at for t = [-4, 4] for a= 0.5, 1.5. Comment on the
effect
of time scaling.
CODE:
t=-4:.1:4;
a=0.5;
b=exp(-2(a*t));
subplot(2,1,1)
plot(t,b);
xlabel(‘time(t)’)
a1=1.5;
b1=exp(-2(a*t));
subplot(2,1,2)
plot(t,b1);
xlabel(‘time(t)’)
OUTPUT:
60
40
20
0
-4 -3 -2 -1 0 1 2 3 4
time(t)
60
40
20
0
-4 -3 -2 -1 0 1 2 3 4
time(t)
OUTPUT:
POST LAB EXERCISE:
1.Generate the waveform of following signals:
For CT signals, t = is -10 to 10 sec
Take appropriate value of sampling interval.
a. xa(t) = δ(t + 1)
ans:-
t=-10:1:10;
u=1.*(t==-1)+0.*(t<-1)+0.*(t>-1);
plot(t,u);
xlabel('time(t)')
OUTPUT:
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
time(t)
CODE:
t=-10:10;
u=(1.*(t==-0.5)+0.*(t<-0.5)+0.*(t>-0.5))-(1.*(t==0.5)+0.*(t<0.5)+0.*(t>0.5));
plot(t,u);
xlabel('time(t)')
OUTPUT:
1
0.8
0.6
0.4
0.2
-0.2
-0.4
-0.6
-0.8
-1
-10 -8 -6 -4 -2 0 2 4 6 8 10
time(t)
c. xc(t) = t u(t)
CODE:
t=-10:10;
u=t.*(1.*(t>0)+0.*(t<0));
plot(t,u);
xlabel('time(t)')
OUTPUT:
10
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
time(t)
CODE:
t=-10:10;
u=(1.*(t>-2)+0.*(t<-2))-(1.*(t>5)+0.*(t<5));
plot(t,u);
xlabel('time(t)')
OUTPUT:
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
time(t)
CODE:
t=-10:.01:10;
r=(t.*(t>-1))+(0.*(t<-1))-(t.*(t>0))-(0.*(t<0))+(t.*(t>2))+(0.*(t<2));
plot(t,r);
xlabel('time(t)')
OUTPUT:
10
-2
-10 -8 -6 -4 -2 0 2 4 6 8 10
time(t)
t=-10:.01:10;
y=(exp(-t).*sin(2.*pi.*t))+(exp(-t/2).*cos(5.*pi.*t));
plot(t,y);
xlabel('time(t)')
ylabel('y(t)')
OUTPUT:
4
x 10
2
1.5
0.5
y (t)
-0.5
-1
-1.5
-10 -8 -6 -4 -2 0 2 4 6 8 10
time(t)
a. xa[n] = r[-n]
CODE:
n=-5:1:5;
y=(-n).*(n<0)+0.*(n>0)+(-n).*(n==0);
stem(n,y);
xlabel('time(seconds)');
ylabel('r[-n]');
OUTPUT:
5
4.5
3.5
3
r[ -n ]
2.5
1.5
0.5
0
-5 -4 -3 -2 -1 0 1 2 3 4 5
time(seconds)
b. xb[n] = exp(n-1)
CODE:
n=-5:1:5;
y=exp(n-1);
stem(n,y);
xlabel('time(seconds)')
ylabel('exp(n-1)');
OUTPUT:
60
50
40
exp(n-1)
30
20
10
0
-5 -4 -3 -2 -1 0 1 2 3 4 5
time(seconds)
c. xc[n] = [n - 1] δ[n - 2]
CODE:
n=-5:1:5;
y=(n-1).*((1.*(n==2))+(0.*(n<2))+(0.*(n>2)));
stem(n,y);
xlabel('time(seconds)');
ylabel('[n-1]impulse[n-2]');
OUTPUT:
1
0.9
0.8
0.7
[n -1 ]im p u ls e [n -2]
0.6
0.5
0.4
0.3
0.2
0.1
0
-5 -4 -3 -2 -1 0 1 2 3 4 5
time(seconds)
CODE:
n=-5:1:5;
y=1.*(n>(-1))+0.*(n<(-1))+1.*(n>1)+0.*(n<1)-2.*1.*(n>0)+0.*(n<0);
stem(n,y);
xlabel('time(seconds)');
ylabel('y(t)');
OUTPUT:
1
0.8
0.6
0.4
0.2
y(t)
-0.2
-0.4
-0.6
-0.8
-1
-5 -4 -3 -2 -1 0 1 2 3 4 5
time(seconds)
e. xe[n] = r [n + 3] – r [n - 3]
CODE:
n=-5:1:5;
y=n.*(n>-3)+n.*(n==-3)+0.*(n<-3)-(n.*(n>3)+n.*(n==3)+0.*(n<3));
stem(n,y);
xlabel('time(seconds)');
ylabel('y(t)');
OUTPUT:
OUTPUT:
35
30
25
20
y(t)
15
10
0
-5 -4 -3 -2 -1 0 1 2 3 4 5
time(seconds)
LEARNING OUTCOMES:-
a)Stem: stem (n, x (n)); plots the discrete function x(n) vs. n.
Stem: stem (n, Y (n)); plots the data sequence Y as stems the x axis terminated
with circles for the data value. If Y is a matrix then each column is plotted as a
separate series.