Commit 51078d88 authored by 袁通's avatar 袁通
Browse files

update lab 2

parent d52af4a5
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
% Problem 2.5(d)

a = [1 -3/5];
b = 1;
x = [1 zeros(1,19)];


h1 = filter(b, a, x);
h2 = zeros(1,21);

nh = 0:19;

for i = 2:21
    h2(i) = ((3/5)^(i-2)) * h2(i-1) + x(i-1)
end

h2 = h2(2:end);

subplot(2, 1, 1);
stem(nh, h1);
title('y_1[n]=(3/5)y_1[n-1]+x[n]');
xlabel('n');
ylabel('h_1[n]');

subplot(2, 1, 2);
stem(nh, h2);
title('y_2[n]=(3/5)^ny_1[n-1]+x[n]');
xlabel('n');
ylabel('h_2[n]');

saveas(gcf, "plots/P2_5_d_out.png");

close;
 No newline at end of file
+33 −0
Original line number Diff line number Diff line
% Problem 2.5(e)

a = [1 -3/5];
b = 1;
x = ones(1, 20);


s1 = filter(b, a, x);
s2 = zeros(1,21);

ns = 0:19;

for i = 2:21
    s2(i) = ((3/5)^(i-2)) * s2(i-1) + x(i-1)
end

s2 = s2(2:end);

subplot(2, 1, 1);
stem(ns, s1);
title('y_1[n]=(3/5)y_1[n-1]+x[n]');
xlabel('n');
ylabel('s_1[n]');

subplot(2, 1, 2);
stem(ns, s2);
title('y_2[n]=(3/5)^ny_1[n-1]+x[n]');
xlabel('n');
ylabel('s_2[n]');

saveas(gcf, "plots/P2_5_e_out.png");

close;
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
% Problem 2.5(f)
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
% Problem 2.5(g)
 No newline at end of file
+20.1 KiB
Loading image diff...
Loading