% Problem 1.3
%

figure(1); clf

[x2,n2] = stepseq(-10,-35,35);
[x3,n3] = stepseq(20,-35,35);
[x,n] = sigadd(x2,n2,-x3,n3);
[x1,n1]   = sigmult(n,n,x,n)

subplot(4,1,1); stem(n1,x1); title('Sequence in Exercise 1.3')
xlabel('n'); ylabel('x1(n)'); axis([min(n1)-1,max(n1)+1,min(x1)-1,max(x1)+1])
set(gca,'XTickMode','manual','XTick',[min(n1),0,max(n1)])

[x2,n2] = stepseq(0,-35,35);
[x3,n3] = stepseq(30,-35,35);
[x,n] = sigadd(x2,n2,-x3,n3);
xc = cos(0.1*pi*n);
[x2,n2] = sigmult(x,n,xc,n);

subplot(4,1,2); stem(n2,x2); title('Sequence in Exercise 1.3')
xlabel('n'); ylabel('x2(n)'); axis([min(n2)-1,max(n2)+1,min(x2)-1,max(x2)+1])
set(gca,'XTickMode','manual','XTick',[min(n2),0,max(n2)])

[x3,n3] = conv_m(x1,n1,x2,n2);

subplot(4,1,3); stem(n3,x3); title('Sequence in Exercise 1.3')
xlabel('n'); ylabel('x3(n)'); axis([min(n3)-1,max(n3)+1,min(x3)-1,max(x3)+1])
set(gca,'XTickMode','manual','XTick',[min(n3),0,max(n3)])

[x4,n4] = conv_m(x2,n2,x1,n1);

subplot(4,1,4); stem(n4,x4); title('Sequence in Exercise 1.3')
xlabel('n'); ylabel('x4(n)'); axis([min(n4)-1,max(n4)+1,min(x4)-1,max(x4)+1])
set(gca,'XTickMode','manual','XTick',[min(n4),0,max(n4)])

