Commit 7ddd615a authored by 袁通's avatar 袁通
Browse files

update lab 2

parent 7ea0cc71
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ y2 = conv(x1, conv(h1, h2));
ny = nh1(1)+nx1(1):1:nh1(end)+nh1(end)+nx1(end)

subplot(2,1,1), stem(ny, y1), title("y_2[n]=(x_1[n]*h_1[n])*h_2[n]");
subplot(2,1,2), stem(ny, y2), title("y_1[n]=x_1[n]*(h_1[n]+h_2[n])");
subplot(2,1,2), stem(ny, y2), title("y_1[n]=x_1[n]*(h_1[n]*h_2[n])");

saveas(gcf, "plots/P2_4_d_out.png");
close;
+8 −7
Original line number Diff line number Diff line
% Problem 2.4(e)

% TODO Check it!!!!
x1 = [1 1 1 1 0 0 0 0 0 0];
nx1 = 0:1:9;

@@ -21,18 +21,19 @@ ye2_inter = conv(he2, x1)

subplot(3,1,1);
hold on
stem(nye1, ye1);
stem(nye1, ye1_inter);
stem(nye1, ye1, 'm--s');
stem(nye1, ye1_inter, 'r--p');
legend('y_{e1}[n] = x_1[n]*h_{e1}[n]', 'y_{e1}[n] = x_1[n]*h_{e1}[n]', 'Location', 'northeast');

subplot(3,1,2);
hold on
stem(nye2, ye2);
stem(nye2, ye2_inter);
stem(nye2, ye2, 'm--s');
stem(nye2, ye2_inter, 'r--p');

subplot(3,1,3);
hold on
stem(nye1, ye1);
stem(nye2, ye2);
stem(nye1, ye1, 'm--s');
stem(nye2, ye2, 'r--p');

saveas(gcf, "plots/P2_4_e_out.png");
close;
+11 −7
Original line number Diff line number Diff line
% Problem 2.4(f)

x1 = [1 1 1 1 0 0 0 0 0 0];
nx1 = 0:1:9;
nx1 = 0:9;

h1 = [1 -1 3 0 1];
h2 = [0 2 5 4 -1];
nh1 = 0:1:4;
nh1 = 0:4;

w = x1.*(nx1+1);
hw = nx1;
@@ -23,13 +23,17 @@ hseries = conv(hf1, hf2);
nhseries = (nhf1(1)+nhf2(1)):1:(nhf1(end)+nhf2(end));

yf2 = conv(x1, hseries);
nyf2 = (x1(1)+nhseries(1)):1:(x1(end)+nhseries(end));
nyf2 = (nx1(1)+nhseries(1)):(nx1(end)+nhseries(end));

figure;
stem(nyf1, yf1);
stem(nyf2, yf2);

saveas(gcf, "P2_4_f_out.png");
hold on
stem(nyf1, yf1, 'm--s');
stem(nyf2, yf2, 'r--p');
title('y_{f1}[n] & y_{f2}[n]');
legend('y_{f1}[n]', 'y_{f2}[n]', 'Location', 'northeast');
xlabel('n');

saveas(gcf, "plots/P2_4_f_out.png");
close;


LAB2/P2_4_f_out.png

0 → 100644
+12.2 KiB
Loading image diff...
+6 −2
Original line number Diff line number Diff line
@@ -30,8 +30,12 @@ hparallel = hg1 + hg2;
yg2 = conv(xg, hparallel);
nyg2 = nyg1;

stem(nyg1, yg1);
stem(nyg2, yg2);
figure;
hold on;
stem(nyg1, yg1, 'm--s');
stem(nyg2, yg2, 'r--p');
title('y_{g1}[n] & y_{g2}[n]');
legend('y_{g1}[n]', 'y_{g2}[n]', 'Location', 'northeast');

saveas(gcf, "plots/P2_4_g_out.png");
close;
Loading