You are on page 1of 4

Zara Noor BSCE19013

Digital signals processing lab


Task 1
(a)

Code
n= 1:50;
s = sin(2*pi*n/50);
stem(n,s);
xlabel('n 1 : 50 ');
ylabel('s sin(2*pi*n/50)');
title('label x-axis and label y-axis');

Task 1(b)
1. max(s) = 0.998026
2. min(s) = -0.998026
3. mean(s) = -2.1552e-17
4. mean(s.^2) = 0.5000
5. rms(s) = 0.7071
6. Energy =25.0000
Task 1 (C)
1. Signal duration= 101
2. Energy= 50.0000
3. Average power= 0.4950
4. RMS Value= 0.7036
Task 2
Code
I. n=-3:6;
s =[0 0 0 2 0 3 -1 0 2 -3];
stem(n,s)
title('Input signal');

II. when nd is negative

n=-3:7;
signal =[0 0 0 2 0 3 -1 0 2 -3 0];
nd=-5;
if (nd<0)
n1=n-abs(nd);
subplot(2,1,1);
stem(n,signal);
title('signal before shifting');
subplot(2,1,2);
stem(n1,signal);
title('after shifiting signal ');
end
III. when nd is positive

n=-3:7;
signal =[0 0 0 2 0 3 -1 0 2 -3 0];
nd=5;
if (nd>=0)
n1=nd+n;
subplot(2,1,1);
stem(n,signal);
title('Input Signal');
subplot(2,1,2);
stem(n1,signal);
title('Shifted Signal');
end
Task (b)
ni=input('Enter ni:');
nh=input('Enter nh:');
t= (ni-5:0.01:nh+5);
unitstep = t<ni;
unitstep2 = t>nh;
z=-(unitstep2 + unitstep)+1;
plot(t,z);
title('Unit step');

You might also like