% Problem 1.3(a)
nx = [-3:7];
x = zeros(1,length(n));
x(4) = 2;
x(6) = 1;
x(7) = -1;
x(8) = 3;

stem(nx,x);
title('Problem 1.3(a)');

% Problem 1.3(b)
ny1 = nx+2;    y1 = x;
ny2 = nx-1;    y2 = x;
ny3 =  -nx;    y3 = x;
ny4 = 1-nx;    y4 = x;

% Problem 1.3(c)
figure;
subplot(411); stem(ny1,y1); title('y_1');
subplot(412); stem(ny2,y2); title('y_2');
subplot(413); stem(ny3,y3); title('y_3');
subplot(414); stem(ny4,y4); title('y_4');

% Problem 1.6(a)
x  = sym('sin(2*pi*t/T)');
x5 = subs(x,5,'T');
figure;
ezplot(x5,[0:10]);
title('Problem 1.6(a)');

% Problem 1.6(b)
x   = sym('cos(2*pi*t/T)*sin(2*pi*t/T)');
x4  = subs(x,4,'T');
x8  = subs(x,8,'T');
x16 = subs(x,16,'T');
figure 
subplot(311);
ezplot(x4,[0,32]);
title('T = 4');
subplot(312);
ezplot(x8,[0,32]);
title('T = 8');
subplot(313);
ezplot(x16,[0,32]);
title('T = 32');

% Problem 1.6(c)
x  = sym('exp(-a*t)*cos(2*pi*t)');
const = sym('0.1');
x2 = subs(x,0.5,'a');
x4 = subs(x,0.25,'a');
x8 = subs(x,0.125,'a');
figure;
subplot(311);
ezplot(x2,[0,10]);
ylim([-1,1]);
hold on;
ezplot(const,[0,10]);
title('a = 1/2');

subplot(312);
ezplot(x4,[0,20]);
ylim([-1,1]);
hold on;
ezplot(const,[0,20]);
title('a = 1/4');

subplot(313);
ezplot(x8,[0,30]);
ylim([-1,1]);
hold on;
ezplot(const,[0,30]);
title('a = 1/8');