0% found this document useful (0 votes)
24 views5 pages

PROB2 36a

This document contains MATLAB code that defines and plots various input, output, and impulse response signals for a discrete-time linear system. It defines input signals x1, x2, and x3, computes the combined signal delta, and plots the original and delayed versions. It then defines the output signals y1_n, y2_n, and y3_n based on delta, and plots them. Finally, it computes the impulse response impulse_resp based on the outputs, and plots the original and delayed versions.

Uploaded by

Sundas Faiz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views5 pages

PROB2 36a

This document contains MATLAB code that defines and plots various input, output, and impulse response signals for a discrete-time linear system. It defines input signals x1, x2, and x3, computes the combined signal delta, and plots the original and delayed versions. It then defines the output signals y1_n, y2_n, and y3_n based on delta, and plots them. Finally, it computes the impulse response impulse_resp based on the outputs, and plots the original and delayed versions.

Uploaded by

Sundas Faiz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

clc;

close all;

n1 = -3:1:4; n2 = n1; n3 = n1;

%Input Plots

x1 = [0 0 -2 1 -2 0 0 0]';
x2 = [0 0 -2 1 0 0 0 0]';
x3 = [0 0 0 1 1 0 0 0]';

for k=1:3
eval(['subplot (3,1,' num2str(k) '); stem (n' num2str(k)...
',x' num2str(k) ');'])
grid on; xlabel('time'); ylabel('amplitude');
eval(['title (''X' num2str(k) '[n]'');']);
end

%Delayed Input Plots

delta=0.5*x1-0.5*x2+x3; delay_delta = delayseq(delta,1);

figure();
subplot (2,1,1); stem (n1,delta);
grid on; xlabel('time'); ylabel('amplitude');
title('delta(n) Impulse');

1
subplot (2,1,2); stem (n1,delay_delta);
grid on; xlabel('time'); ylabel('amplitude');
title('delta(n-1) Shifted Impulse');

%Computing y1[n], y2[n] and y3[n]

y1_n = -delayseq(delta,-1)+3*delta+3*delayseq(delta,1)+delayseq(delta,3);
y2_n = -delayseq(delta,-1)+delta-3*delayseq(delta,1)-delayseq(delta,3);
y3_n = 2*delayseq(delta,-2)+delayseq(delta,-1)-3*delta+2*delayseq(delta,2);

figure();
for k=1:3
eval(['subplot (3,1,' num2str(k) '); stem (n' num2str(k)...
',y' num2str(k) '_n);'])
grid on; xlabel('time'); ylabel('amplitude');
eval(['title (''Y' num2str(k) '[n]'');']);
end

2
%Delayed output Plots

impulse_resp = 0.5*y1_n-0.5*y2_n+y3_n;
delay_impulse_resp = delayseq(impulse_resp,1);

figure();
subplot (2,1,1); stem (n1,impulse_resp);
grid on; xlabel('time'); ylabel('amplitude');
title('L(delta(n)) Impulse Response');
subplot (2,1,2); stem (n1,delay_impulse_resp);
grid on; xlabel('time'); ylabel('amplitude');
title('L(delta(n-1)) Shifted Impulse Response');

3
Part b

h_n= 2*delayseq(delta,-2)+delayseq(delta,-1)-2*delta+3*delayseq(delta,1)...
+2*delayseq(delta,2)+delayseq(delta,3);
figure()
stem(n1,h_n);
grid on; xlabel('time'); ylabel('amplitude');
title('h(n)');

4
5

You might also like