Name:K.Shanmukha Priya Id - No:180040542 Section:S3
Name:K.Shanmukha Priya Id - No:180040542 Section:S3
Name:K.Shanmukha Priya Id - No:180040542 Section:S3
NO:180040542 SECTION:S3
SNAP:
QUESTIONS:
ANSWERS:
A.clear all;
close all;
clc;
h1=[0.5 1 0.5]
h2=fliplr(h1);
N= length(h2);n=-N+1:0;k=-N+1:0;
stem(n,h2);
magh2 = abs(h2); phah2 = angle(h2)*180/pi;
% Plot the frequency response
subplot(3,1,1); stem(n,h2,'r','fill','LineWidth',1.5);
grid
xlabel('n---->');
ylabel('Magnitude---->');
title('Original Sequence');
axis([-1 8 -0.2 1.2]);
subplot(3,1,2); stem(n,magh2,'b','fill','LineWidth',1.5);
grid
xlabel('frequency K ---->');
ylabel('Magnitude ---->') ;
title('Magnitude Spectrum');
axis([-1 N -0.2 max(magh2)+1]);
subplot(3,1,3);
stem(n,phah2,'m','fill','LineWidth',1.5);grid
xlabel('frequency n ---->');
ylabel('Radians---->');
title('Phase Spectrum');
axis([-1 N min(phah2)-10 max(phah2)+10]);
OUTPUT;
C.clear all;
close all;
clc;
h1=[0.5 1 0.5]
h2=fliplr(h1);
h=conv(h1,h2);
N= length(h);n=-N+1:0; k=-N+1:0;
stem(n,h);
magh = abs(h); phah = angle(h)*180/pi;
% Plot the frequency response
subplot(3,1,1); stem(n,h,'r','fill','LineWidth',1.5);
grid
xlabel('n---->');
ylabel('Magnitude---->');
title('Original Sequence');
axis([-1 8 -0.2 1.2]);
subplot(3,1,2); stem(n,magh,'b','fill','LineWidth',1.5);
hold on;
plot(k,magh,'--k','LineWidth',1);
xlabel('frequency K ---->');
ylabel('Magnitude ---->') ;
title('Magnitude Spectrum'); grid
axis([-1 N -0.2 max(magh)+1]);
subplot(3,1,3);
stem(n,phah,'m','fill','LineWidth',1.5);hold on;
plot(n,phah,'--k','LineWidth',1);
xlabel('frequency K ---->');
ylabel('Radians---->');
title('Phase Spectrum');grid
axis([-1 N min(phah)-10 max(phah)+10]);
OUTPUT;
D. clear all;
close all;
clc;
h1=[0.5 1 0.5]
h2=fliplr(h1);
h=conv(h1,h2);
x = [0,0,1];
y = conv(x, h);
M = length(y)-1;
n = 0:1:M;
disp('output sequence');disp(y)
figure();
subplot(3,1,1);stem(0:length(x)-1,x, 'pr', 'fill',
'LineWidth', 1.5);
xlabel('Time index n ---->'); ylabel('Amplitude---->');
title('Input Sequence x[n]');%grid on;
axis([-2 M+1 min(x)-1 max(x)+1]);
subplot(3,1,2);stem(0:length(h)-1,h, 'pb', 'fill',
'LineWidth', 1.5);
xlabel('Time index n ---->'); ylabel('Amplitude---->');
title('Input Sequence h[n]');%grid on;
axis([-2 M+1 min(h)-1 max(h)+1]);
subplot(3,1,3);stem(n,y, 'pm', 'fill', 'LineWidth', 1.5);
xlabel('Time index n ---->'); ylabel('Amplitude---->');
title('Convolutional Output y[n]'); %grid on;
axis([-2 M+1 min(y)-1 max(y)+1]);
OUTPUT;
SIGN