Вы находитесь на странице: 1из 14

EXPERIMENT-2

OBJECTIVE:

I.Elementary continuous time signals:


a). sinusoidal function, x(t) = 3*sin(2*pi*f*t), where f = 20Hz
b) impulse function, x(t) = δ(t)
c) step function, x(t) = u(t)
d) ramp function, x(t) = r(t)
e) exponential function, x(t) = e-at

II. Elementary discrete time signals:


a) sinusoidal function, y[n] = 3*sin (2*pi*n),
b) impulse function y[n] = δ[n]
c) step function , y[n] = u[n]
d) ramp function , y[n] = r[n]
e) exponential function, y[n] = an

III. Generate rectangular, sinc and triangle function.

RESOURCE REQUIRED:

MATLAB software and the tutorial on signal plotting.

THEORY:

A continuous -time signal x(t) is a continuous function of an independent variable t, that is time.
A discrete-time signal y(n) is a function of an independent variable n, that is an integer.

We used the following functions for the lab exercise-

plot: plot(t, x(t)); plots the continuous function x(t) vs. t.


stem: stem(n, x(n); plots the discrete function x(n) vs. n.
POST LAB EXERCISE:

Q1. Generate the waveform of following signals:

For CT signals, t = is -10 to 10 sec


Take appropriate value of sampling interval.

a. x(t) = δ(t + 2)

Source Code:

t=-10:0.01:10
for i=1:length(t)
if(t(i)==-2)
d(i)=1
else
d(i)=0
end
end
plot(t,d)

Output:
b. x(t) = δ(t + 2) - δ(t -2)

Source Code:
dt=0.01
t=-10:dt:10
x=1.*(t==-2) + 0.*(t~=0) + (-1).*(t==2)
plot(t,x)

Output:
c. x(t) = t u(t)

Source Code:
dt=0.1
t=-10:dt:10
if(t<0)
u=0
else
u=1
end
x=t*u
plot(t,x)

Output:
d. x (t) = u (t) – u(t - 5)

Source Code:
dt=0.01
t=-10:dt:10
y=1.*(t>=0) + 0.*(t<0)
x=0.*(t<5) + 1.*(t>=5)
plot(t,y-x)

Output:
e. x (t) = r (t +1) – r (t) + r (t - 2)

Source Code:

dt=0.01
t=-10:dt:10
y1=(t+1).*(t>=-1) + 0.*(t<-1)
y2=t.*(t>=0) + 0.*(t<0)
y3=(t-2).*(t>=2) + 0.*(t<2)
y=y1-y2+y3
plot(t,y)

Output:
f. x (t) = exp(-t) sin(2πt) + exp(-t/2) cos(5 πt)

Source Code:
dt=0.01
t=-10:dt:10
y1=exp(-t).* sin(2*pi*t)
y2=exp(-t/2).* cos(5*pi*t)
y=y1+y2
plot(t,y)

Output:
For DT signals, n = -5 to 5 samples

g. x[n] = r[-n]

Source Code:

dn=1
n=-5:dn:5
x=(-n) .* (n<=0)
stem(n,x)

Output:
h. x[n] = exp(n-1)

Source Code:
dn=1
n=-5:dn:5
x=exp(n-1)
stem(n,x)

Output:

i. x [n] = [n - 1] δ[n - 2]
Source Code:
dn=1
n=-5:dn:5
x1=1.*(n==2) + 0.*(n~=2)
x2=(n-1).*x1
stem(n,x2)

Output:

j. x [n] = u [n + 1] – 2u[ n] + u [n-1]


Source Code:
dn=1
n=-5:dn:5
x1=1.*(n+1>=0) + 0.*(n<-1)
x2=1.*(n>=0) + 0.*(n<0)
x3=1.*(n>=1) + 0.*(n<1)
x=x1- 2*x2 + x3
stem(n,x)

Output:

k. x [n] = r [n + 2] – r [n - 2]
Source Code:

dn=1
n=-5:dn:5
x1=(n+2).*(n>=-2) + 0.*(n<-2)
x2=(n-2).*(n>=2) + 0.*(n<2)
x3=x1-x2
stem(n,x3)

Output:

l. x [n] = an cos(2 πn)


Source Code:

a=3
dn=1
n=-5:dn:5
x=(a.^n) .* (cos(2*pi*n))
stem(n,x)

Output:

Q2. Sketch the given waveform:


Source Code:
dt=0.01
t=-10:dt:10
y1=-2.*(t+1==0) + 0.*(t~=-1)
y2=2.*(t>=-1) + 0.*(t<-1)
y3=2.*(t>=1) + 0.*(t<1)
y4=-1.*(t-2==0) + 0.*(t~=2)
y5=1.*(t-2==0) + 0.*(t~=2)
y=y2-y3
y6=-1.*(t>=2) + 0.*(t<2)
y7=1.*(t>=4) + 0.*(t<4)
y8=y6+y7
y9=-1.*(t>=5)+0.*(t<5)
y10=1.*(t>=7)+0.*(t<7)
y11=y9+y10
y12=1.*(t==7) + 0.*(t~=7)
plot(t,y1,t,y,t,y4,t,y5,t,y8,t,y11,t,y12)

Output:

LEARNING OUTCOME: We studied and plotted different kind of continuous time signals and
discrete time signals using matlab.

Вам также может понравиться