function class32()
%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;

close all;

addpath(genpath('../matlab/'))
namebase = ['./'];
Ts = 0.01; Fs = 1/Ts;
T0 = 1000;

n = 1;


% UPSAMPLING
fnc{n} = @stem; 
x{n} = -10:1:10;
y{n} = sinc(x{n}/4).^2;
xlbl{n} = 'n'; ylbl{n} = 'x[n]'; figwidth{n} = 3.33; 
ynum{n} = false;
axis{n} = [-10 10 -0.1 1];
caption{n} = 'Original signal $x[n]$.';
markersize{n} = 6; n = n + 1;

fnc{n} = @plot; 
x{n} = linspace(-4-.001,4+.001,T0);
y{n} = triangularPulse(-1/2+0,0,1/2+0,mod(x{n},2)) + triangularPulse(-1/2+0,0,1/2+0,mod(-x{n},2));
xlbl{n} = '\omega'; ylbl{n} = 'X(\omega)'; figwidth{n} = 3.33; 
axis{n} = [-4 4 -0.1 2];
xTickSuffix{n}  = '\pi'; 
caption{n} = 'DTFT of $x[n]$.';
markersize{n} = 6; n = n + 1;



fnc{n} = @stem; 
x{n} = -20:1:20;
y{n} = zeros(1,2*(length(x{n-2})-1)+1); y{n}(1:2:end) = y{n-2};
xlbl{n} = 'n'; ylbl{n} = 'x[n]'; figwidth{n} = 3.33; 
ynum{n} = false;
axis{n} = [-20 20 -0.1 1];
caption{n} = '$x[n]$ after upsampling by 2.';
markersize{n} = 6; n = n + 1;

fnc{n} = @plot; 
x{n} = linspace(-4-.001,4+.001,T0);
y{n} = triangularPulse(-1/4+0,0,1/4+0,mod(x{n},1)) + triangularPulse(-1/4+0,0,1/4+0,mod(-x{n},1));
xlbl{n} = '\omega'; ylbl{n} = 'X(\omega)'; figwidth{n} = 3.33; 
axis{n} = [-4 4 -0.1 2];
xTickSuffix{n}  = '\pi'; 
caption{n} = 'DTFT of $x[n]$ after upsampling by 2.';
markersize{n} = 6; n = n + 1;





fnc{n} = @stem; 
x{n} = -10:1:10;
y{n} = sinc(x{n}/4).^2;
xlbl{n} = 'n'; ylbl{n} = 'x[n]'; figwidth{n} = 3.33; 
ynum{n} = false;
axis{n} = [-10 10 -0.1 1];
caption{n} = 'Original signal $x[n]$.';
markersize{n} = 6; n = n + 1;

fnc{n} = @plot; 
x{n} = linspace(-4-.001,4+.001,T0);
y{n} = triangularPulse(-1/2+0,0,1/2+0,mod(x{n},2)) + triangularPulse(-1/2+0,0,1/2+0,mod(-x{n},2));
xlbl{n} = '\omega'; ylbl{n} = 'X(\omega)'; figwidth{n} = 3.33; 
axis{n} = [-4 4 -0.1 2];
xTickSuffix{n}  = '\pi'; 
caption{n} = 'DTFT of $x[n]$.';
markersize{n} = 6; n = n + 1;



fnc{n} = @stem; 
x{n} = -30:1:30;
y{n} = zeros(1,3*(length(x{n-2})-1)+1); y{n}(1:3:end) = y{n-2};
xlbl{n} = 'n'; ylbl{n} = 'x[n]'; figwidth{n} = 3.33; 
ynum{n} = false;
axis{n} = [-20 20 -0.1 1];
caption{n} = '$x[n]$ after upsampling by 3.';
markersize{n} = 6; n = n + 1;

fnc{n} = @plot; 
x{n} = linspace(-4-.001,4+.001,T0);
y{n} = triangularPulse(-1/2/3+0,0,1/2/3+0,mod(x{n},2/3)) + triangularPulse(-1/2/3+0,0,1/2/3+0,mod(-x{n},2/3));
xlbl{n} = '\omega'; ylbl{n} = 'X(\omega)'; figwidth{n} = 3.33; 
axis{n} = [-4 4 -0.1 2];
xTickSuffix{n}  = '\pi'; 
caption{n} = 'DTFT of $x[n]$ after upsampling by 3.';
markersize{n} = 6; n = n + 1;






fnc{n} = @stem; 
x{n} = -10:1:10;
y{n} = sinc(x{n}/4).^2;
xlbl{n} = 'n'; ylbl{n} = 'x[n]'; figwidth{n} = 3.33; 
ynum{n} = false;
axis{n} = [-10 10 -0.1 1];
caption{n} = 'Original signal $x[n]$.';
markersize{n} = 6; n = n + 1;

fnc{n} = @plot; 
x{n} = linspace(-4-.001,4+.001,T0);
y{n} = triangularPulse(-1/2+0,0,1/2+0,mod(x{n},2)) + triangularPulse(-1/2+0,0,1/2+0,mod(-x{n},2));
xlbl{n} = '\omega'; ylbl{n} = 'X(\omega)'; figwidth{n} = 3.33; 
axis{n} = [-4 4 -0.1 2];
xTickSuffix{n}  = '\pi'; 
caption{n} = 'DTFT of $x[n]$.';
markersize{n} = 6; n = n + 1;


fnc{n} = @stem; 
x{n} = -20:1:20;
y{n} = zeros(1,2*(length(x{n-2})-1)+1); y{n}(1:2:end) = y{n-2};
xlbl{n} = 'n'; ylbl{n} = 'x[n]'; figwidth{n} = 3.33; 
ynum{n} = false;
axis{n} = [-20 20 -0.1 1];
caption{n} = '$x[n]$ after upsampling by 2.';
markersize{n} = 6; n = n + 1;

fnc{n} = @plot; 
x{n} = linspace(-4-.001,4+.001,T0);
y{n} = triangularPulse(-1/4+0,0,1/4+0,mod(x{n},1)) + triangularPulse(-1/4+0,0,1/4+0,mod(-x{n},1));
xlbl{n} = '\omega'; ylbl{n} = 'X(\omega)'; figwidth{n} = 3.33; 
axis{n} = [-4 4 -0.1 2];
xTickSuffix{n}  = '\pi'; 
caption{n} = 'DTFT of $x[n]$ after upsampling by 2.';
markersize{n} = 6; n = n + 1;


fnc{n} = @stem; 
x{n} = -20:1:20;
y{n} = resample(y{n-4}, 2, 1); y{n} = y{n}(1:(end-1));
xlbl{n} = 'n'; ylbl{n} = 'x[n]'; figwidth{n} = 3.33; 
ynum{n} = false;
axis{n} = [-20 20 -0.1 1];
caption{n} = '$x[n]$ after upsampling by 2 and applying the reconstruction/interpolation filter.';
markersize{n} = 6; n = n + 1;

fnc{n} = @plot; 
x{n} = linspace(-4-.001,4+.001,T0);
y{n} = 2*(triangularPulse(-1/4+0,0,1/4+0,mod(x{n},2)) + triangularPulse(-1/4+0,0,1/4+0,mod(-x{n},2)));
xlbl{n} = '\omega'; ylbl{n} = 'X(\omega)'; figwidth{n} = 3.33; 
axis{n} = [-4 4 -0.1 2];
xTickSuffix{n}  = '\pi'; 
caption{n} = 'DTFT of $x[n]$ after upsampling by 2 and applying the reconstruction/interpolation filter.';
markersize{n} = 6; n = n + 1;











% t{ 8} = -10:1:10;    ticks{ 8} = [-40:5:40];   x{ 8} = sinc(t{ 8}/8).^2;
% t{ 9} = -20:1:20;    ticks{ 9} = [-80:5:80];   x{ 9} = zeros(1,2*(length(t{8})-1)+1); x{9}(1:2:end) = x{ 8};
% t{10} = -20:1:20;    ticks{10} = [-80:5:80];   x{10} = resample(x{8}, 2, 1); x{10} = x{ 10}(1:(end-1));




pltopt{n} = [];
figheight{n} = [];
axis{n} = [];
figwidth{n} = [];
hidexticks{n}  = [];
hideyticks{n}  = [];
marker{n} = [];
markersize{n} = [];
xTickPrefix{n} = [];
xTickSuffix{n} = [];
yTickPrefix{n} = [];
yTickSuffix{n} = [];
LineStyleOrder{n} = [];
ynum{n} = [];
pzplot{n} = [];
roc{n} = [];
myColorMap{n} = [];
xTick{n} = []; 
yTick{n} = [];
pzzplot{n} = [];
textloc{n} = [];
textcont{n} = '';
caption{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}, ...
                  'hidexticks', hidexticks{n}, 'hideyticks', hideyticks{n}, 'marker', marker{n}, ...
                  'markersize', markersize{n}, 'axis', axis{n}, ...
                  'xTickPrefix', xTickPrefix{n}, 'yTickPrefix', yTickPrefix{n}, ...
                  'yTickSuffix', yTickSuffix{n}, 'figheight', figheight{n}, ...
                  'xTickSuffix', xTickSuffix{n}, 'LineStyleOrder', LineStyleOrder{n}, ...
                  'pltopt', pltopt{n}, 'ynum', ynum{n}, 'pzplot', pzplot{n}, 'roc', roc{n}, ...
                  'myColorMap', myColorMap{n}, 'xTick', xTick{n}, 'yTick', yTick{n}, ...
                  'pzzplot', pzzplot{n}, 'textloc', textloc{n}, 'textcont', textcont{n}, ...
                  'caption', caption{n}, 'captionFile', [namebase 'caption' num2str(n, '%03u') '.html']);
end
