N (0:1:40) A 1.2 F 0.1 X A Cos (2 Pi F N) Stem (N, X,'r','filled') Xlabel ('TIME') Ylabel ('AMPLITUDE')
N (0:1:40) A 1.2 F 0.1 X A Cos (2 Pi F N) Stem (N, X,'r','filled') Xlabel ('TIME') Ylabel ('AMPLITUDE')
TASK 1:
▪ Write a script to generate a sinusoidal sequence with Phase Shift =0, Amplitude =1.2,
and Frequency =0.1 for discrete time with 40 samples. Use ‘stem’ command to plot
the generated sequence.
PROGRAM:
n=[0:1:40];
a=1.2;
f=0.1;
x=a*cos(2*pi*f*n);
stem(n,x,'r','filled')
xlabel('TIME')
ylabel('AMPLITUDE')
OUTPUT:
TASK 2:
▪ Explore periodicity property of discrete time sinusoid by plotting two sinusoid x1(n)
and x2(n) with frequencies π/4 and 9π/4 respectively.
▪ What is the period of the sequences x1(n) & x2(n) ?
▪ What is the difference between plots of x1(n) & x2(n)? Why?
PROGRAM:
n=[0:1:40];
a=1.2;
w1=pi/4;
w2=(9*pi)/4;
x1=a*cos(w1*n);
subplot(2,1,1)
stem(n,x1,'r','filled')
xlabel('TIME')
ylabel('AMPLITUDE')
legend('FREQUENCY=-pi/4')
grid on
x2=a*cos(w2*n);
subplot(2,1,2)
stem(n,x2,'b','filled')
xlabel('TIME')
ylabel('AMPLITUDE')
legend('FREQUENCY=9pi/4')
z=(2*pi)/w1
y=(2*pi)/w2
A = ['periodic sequence of x2(n) = ',num2str(y)]
text(1.7,1.7,A,'FontSize',14)
B= ['periodic sequence of x1(n) = ',num2str(z)]
text(1.7,6,B,'FontSize',14)
grid on
OUTPUT:
REASON:
Apparently both of the output of the signals are same but one of the signal is a
wrong signal due to aliasing effect.Aliasing occurs when signal is not sampled
with enough data points and in such condition signal adopted the identifications
of another signal.
In this task signal with frquency 9pi/4 is aliasing signal because its frequency is
not lie in the standard range of discrete time signals i.e -pi to +pi.
TASK 3:
▪ Write a function y=DTimp(n) to generate the discrete time unit impulse function.
PROGRAM:
function y=DTimp(n)
y=(n==0);
stem(n,y,'c','filled','linewidth',4)
xlabel('Time axis')
ylabel('Amplitude')
legend('Unit Impulse Sequence')
grid on;
end
OUTPUT:
TASK 4:
▪ Write a script that uses user input to shift unit impulse right. Use MATLAB input
command to take the number of places to shift the signal right (Delay).
shifted_data = delayseq (data, DELAY)
PROGRAM:
delay=input('ENTER VALUE OF SHIFT= ')
n=[-10:1:10];
X=(n==0);
y=double(X)
y=y'
S=delayseq(y,delay)
stem(n,S,'b','filled','linewidth',4)
xlabel('Time axis')
ylabel('Amplitude')
title('Unit Step Sequence')
grid on;
OUTPUT:
TASK 5:
▪ Write a script that uses user input to shift the unit step sequence advanced by 4
samples.
PROGRAM:
delay=input('ENTER THE VALUE OF ADVANCE= ')
n=[-8:1:8]
y=((n>=0))
z=double(y)
z=z'
S=delayseq(z,-delay:1:8)
stem(n,S,'g','filled','linewidth',4)
xlabel('Time axis')
ylabel('Amplitude')
title('Unit step Sequence')
grid on
OUTPUT:
TASK 6:
▪ Write a function to generate a DT signal defined as:
−𝝅 𝟑𝝅𝒏
𝒈(𝒏) = 𝟏𝟎𝒆 𝟒 𝒔𝒊𝒏 𝒖(𝒏)
𝟏𝟔
PROGRAM:
function g=DT_signal(n)
g=(10*0.4559*sin(3*pi*n/16)).*unit_step(n)
stem(n,g,'r','filled','linewidth',4)
xlabel('TIME')
ylabel('AMPLITUDE')
title('DISCRETE TIME SIGNAL')
end
OUTPUT: