function class05()
%CLASS02  Displays plots for ECE 3500 class
%   CLASS02()  creates all the plots for class lecture notes through the
%   use of Dr. Harley's plotforclass MATLAB function. To get the full
%   results from the lecture notes, this function requires the "export_fig"
%   and "oaxes" functions from the MathWorks File Exchange. 
%
%   INPUTS: none
%
%   OUTPUTS: none
%
%   see also: plot, stem, subplot, figure

close all;

addpath(genpath('../matlab/'))
namebase = ['./'];

n = 1;



%%
% ----------------------------------------------------------------------
% System properties
% ----------------------------------------------------------------------

% Discrete-Time Convolution
dt = 1;
t  = -5:dt:9;
tc = (2*min(t)):dt:(2*max(t));

k = 1;
x1c{k} = (t >= 0) - (t >= 3);
x2c{k} = 1/dt.*(t == 2);
caption{k} = 'Convolution of a box and shifted impulse';
k = k + 1;

x1c{k} = (t >= 0) - (t >= 3);
x2c{k} = (t >= 0) - (t >= 3);
caption{k} = 'Convolution of two boxes';
k = k + 1;

x1c{k} = (t >= 0) - (t >= 3);
x2c{k} = exp(-(1/2)*t).*(t >= 0);
caption{k} = 'Convolution of a box and a stepped exponential';
k = k + 1;

x1c{k} = exp(-(1/2).*t).*(t >= 0);
x2c{k} = exp(-(1/2).*t).*(t >= 0);
caption{k} = 'Convolution of two stepped exponentials';
k = k + 1;

x1c{k} = t.*(t >= 0) - t.*(t >= 3);
x2c{k} = (t >= 0) - (t >= 3);
caption{k} = 'Convolution of a ramp and a box';
k = k + 1;

x1c{k} = randn(length(t),1);
x2c{k} = (t >= 0) - (t >= 3);
caption{k} = 'Convolution of random numbers and a box';
k = k + 1;

x1c{k} = (t >= 0);
x2c{k} = exp(-1.*t).*(t >= 0);
caption{k} = 'Convolution of a step function and stepped exponential';
k = k + 1;

x1c{k} = (t >= 0);
x2c{k} = (t >= 0) - (t >= 2);
caption{k} = 'Convolution of a step function and a box';
k = k + 1;

% x1c{k} = (t >= 0) - (t >= 3);
% x2c{k} = exp(-(1/2)*t).*(t >= 0);
% k = k + 1;
% 
% x1c{k} = exp(-(1/2)*t).*(t >= 0);
% x2c{k} = (t >= 0) - (t >= 3);
% k = k + 1;

% x1c{k} = -1*(t == -1) + 2*(t == 0) + 1*(t == 1);
% x2c{k} = -1*(t == -1) + 2*(t == 0) + 1*(t == 1);
% k = k + 1;
% 
% x1c{k} = -1*(t == -1) + 2*(t == 0) + 1*(t == 1);
% x2c{k} = 1*(t == 1) + 2*(t == 2) + -1*(t == 3);
% k = k + 1;

for n = 1:(k-1)
    
    x1 = double(x1c{n});
    x2 = double(x2c{n});
    
    x3 = conv(x1, x2)*dt;
    x3 = interp1(tc, x3, t);
    
    fnc{n} = @stem; x{n} = t;
    y{n}(:,:,1,1) = padshift(x2, zeros(length(t),1));
    y{n}(:,:,2,1) = padshift(x1, zeros(length(t),1));
    y{n}(:,:,1,2) = padshift(x2, zeros(length(t),1));
    y{n}(:,:,2,2) = padshift(interp1(t,x1,-t, 'linear', 0), round(t/dt));
    y{n}(:,:,3,2) = y{n}(:,:,1,2).*y{n}(:,:,2,2);
    y{n}(:,:,4,2) = x3.'+tril(nan*ones(length(t)),-1);
    hidexticks{n} = true; hideyticks{n} = true; ynum{n} = false;
    figwidth{n} = 6; figheight{n} = 7; 
    gifIt{n} = true; gifDelay{n} = 2;
    for ii = 1:length(t)
        xlbl{n}{ii,1,1} = 'n'; ylbl{n}{ii,1,1} = 'h[n]'; 
        xlbl{n}{ii,2,1} = 'n'; ylbl{n}{ii,2,1} = 'x[n]'; 
        xlbl{n}{ii,1,2} = 'm'; ylbl{n}{ii,1,2} = 'h[m]'; 
        if sign(-t(ii)) == 1, mysign = '-'; else mysign = '+'; end
        xlbl{n}{ii,2,2} = 'm'; ylbl{n}{ii,2,2} = ['x[' mysign num2str(abs(t(ii))) ' - m]']; 
        xlbl{n}{ii,3,2} = 'm'; ylbl{n}{ii,3,2} = ['h[m] x[' mysign num2str(abs(t(ii))) ' - m]']; 
        xlbl{n}{ii,4,2} = 'n'; ylbl{n}{ii,4,2} = 'y[n]'; 
    end
end




n = n + 1;
axis{n}        = [];
figwidth{n}    = [];
figheight{n}   = [];
hidexticks{n}  = [];
hideyticks{n}  = [];
marker{n}      = [];
markersize{n}  = [];
xTickPrefix{n} = [];
xTickSuffix{n} = [];
yTickPrefix{n} = [];
yTickSuffix{n} = [];
xTick{n}       = [];
yTick{n}       = [];
gifIt{n}       = [];
gifDelay{n}    = [];
caption{n}     = [];

figwidth{n} = [];

for n = 1:length(x)
    plotforclass( 'fnc', fnc{n}, 'x', x{n}, 'y', y{n}, ...
                  'flname', [namebase 'fig' num2str(n, '%03u')], ...
                  'xlbl', xlbl{n}, 'ylbl', ylbl{n}, 'figwidth', figwidth{n}, ...
                  'figheight', figheight{n}, ...
                  'hidexticks', hidexticks{n}, 'marker', marker{n}, ...
                  'markersize', markersize{n}, 'axis', axis{n}, ...
                  'xTickPrefix', xTickPrefix{n}, 'xTickSuffix', xTickSuffix{n}, ...
                  'yTickPrefix', yTickPrefix{n}, 'yTickSuffix', yTickSuffix{n}, ...
                  'hideyticks', hideyticks{n}, 'xTick', xTick{n}, 'yTick', yTick{n},...
                  'gifIt', gifIt{n}, 'gifDelay', gifDelay{n}, 'caption', caption{n},...
                  'captionFile', [namebase 'caption' num2str(n, '%03u') '.html']);
end


end

