Commit 3aa7adcd authored by 袁通's avatar 袁通
Browse files

update LAB 2

parent 773ac68b
Loading
Loading
Loading
Loading
+27 −10
Original line number Diff line number Diff line
@@ -3,16 +3,33 @@
x1 = [1 0 0 0 0 0];
x2 = [0 1 0 0 0 0];
x3 = [1 2 0 0 0 0];
nx = 0:5;

function output = myFun(input)
%myFun - Description
%
% Syntax: output = myFun(input)
%
% Long description
    output = [0 0 0 0 0 0]
    for i in input
        if i = 1
xe1 = [0 0 x1];
xe2 = [0 0 x2];
xe3 = [0 0 x3];

w1 = x1;
w2 = x2;
w3 = x3;

for i = 3:8
    w1(i-2) = xe1(i) - xe1(i-1) - xe1(i-2);
    w2(i-2) = xe2(i) - xe2(i-1) - xe2(i-2);
    w3(i-2) = xe3(i) - xe3(i-1) - xe3(i-2);
end

w4 = w1 + 2*w2;

subplot(3, 1, 1), stem(nx, w1), set(get(gca, 'Title'), 'String', 'w_1[n]');
subplot(3, 1, 2), stem(nx, w2), set(get(gca, 'Title'), 'String', 'w_2[n]');

subplot(3, 1, 3)
stem(nx, w3, 'm--s')
hold on
stem(nx, w4, 'r--p')
set(get(gca, 'Title'), 'String', 'w_3[n] & w_4[n]');

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

close;

LAB2/P2_5_a_2.m

0 → 100644
+35 −0
Original line number Diff line number Diff line
% Problem 2.5(a) - 1

x1 = [1 0 0 0 0 0];
x2 = [0 1 0 0 0 0];
x3 = [1 2 0 0 0 0];
nx = 0:5;

xe1 = [0 0 x1];
xe2 = [0 0 x2];
xe3 = [0 0 x3];

w1 = x1;
w2 = x2;
w3 = x3;

for i = 3:8
    w1(i-2) = xe1(i) - xe1(i-1) - xe1(i-2);
    w2(i-2) = xe2(i) - xe2(i-1) - xe2(i-2);
    w3(i-2) = xe3(i) - xe3(i-1) - xe3(i-2);
end

w4 = w1 + 2*w2;

subplot(3, 1, 1), stem(nx, w1), set(get(gca, 'Title'), 'String', 'w_1[n]');
subplot(3, 1, 2), stem(nx, w2), set(get(gca, 'Title'), 'String', 'w_2[n]');

subplot(3, 1, 3)
stem(nx, w3, 'm--s')
hold on
stem(nx, w4, 'r--p')
set(get(gca, 'Title'), 'String', 'w_3[n] & w_4[n]');

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

close;

LAB2/P2_5_a_3.m

0 → 100644
+35 −0
Original line number Diff line number Diff line
% Problem 2.5(a) - 1

x1 = [1 0 0 0 0 0];
x2 = [0 1 0 0 0 0];
x3 = [1 2 0 0 0 0];
nx = 0:5;

xe1 = [0 0 x1];
xe2 = [0 0 x2];
xe3 = [0 0 x3];

w1 = x1;
w2 = x2;
w3 = x3;

for i = 3:8
    w1(i-2) = xe1(i) - xe1(i-1) - xe1(i-2);
    w2(i-2) = xe2(i) - xe2(i-1) - xe2(i-2);
    w3(i-2) = xe3(i) - xe3(i-1) - xe3(i-2);
end

w4 = w1 + 2*w2;

subplot(3, 1, 1), stem(nx, w1), set(get(gca, 'Title'), 'String', 'w_1[n]');
subplot(3, 1, 2), stem(nx, w2), set(get(gca, 'Title'), 'String', 'w_2[n]');

subplot(3, 1, 3)
stem(nx, w3, 'm--s')
hold on
stem(nx, w4, 'r--p')
set(get(gca, 'Title'), 'String', 'w_3[n] & w_4[n]');

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

close;
+17.5 KiB
Loading image diff...