function class27()
%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 = ['./'];

Ts = 0.01; Fs = 1/Ts;


n = 1;
N = 3;

fnc{n} = @stem; 
x{n} = -4:9;
y{n} = (1/2).^(x{n}).*(x{n} >= 0); 
xlbl{n} = 'n'; ylbl{n} = 'h_d[n]'; figwidth{n} = 3.33; 
axis{n} = [-2 9 0 1]; ynum{n} = false;
hideyticks{n}  = false;
caption{n} = 'Non-windowed desired impulse response';
n = n + 1;

fnc{n} = @stem; 
x{n} = -4:9;
y{n} = (1/2).^(x{n}).*(x{n} >= 0).*(x{n} < N); 
xlbl{n} = 'n'; ylbl{n} = 'h[n]'; figwidth{n} = 3.33; 
axis{n} = [-2 9 0 1]; ynum{n} = false;
hideyticks{n}  = false;
caption{n} = 'Windowed desired impulse response';
n = n + 1;

fnc{n} = @plot; 
x{n} = -pi:pi/100:pi;
y0 = freqz(y{n-1}(x{n-1} >= 0), 1, x{n});
y{n} = [abs(1./(1-(1/2).*exp(-1j*x{n}(:)))) abs(y0(:))]; 
xlbl{n} = '\omega'; ylbl{n} = '|H_d(\omega)| and |H(\omega)|'; figwidth{n} = 3.33; 
axis{n} = [-pi pi 0 2]; ynum{n} = false;
hideyticks{n}  = false;
caption{n} = 'Comparing true vs. desired magnitude responses';
n = n + 1;

fnc{n} = @plot; 
x{n} = -pi:pi/100:pi;
y0 = freqz(y{n-2}(x{n-2} >= 0), 1, x{n});
y{n} = [angle(1./(1-(1/2).*exp(-1j*x{n}(:)))) angle(y0(:))]; 
xlbl{n} = '\omega'; ylbl{n} = '\angle H_d(\omega) and \angle H(\omega)'; figwidth{n} = 3.33; 
axis{n} = [-pi pi -pi pi]; ynum{n} = false;
hideyticks{n}  = false;
caption{n} = 'Comparing true vs. desired phase responses';
n = n + 1;




N = 5;

fnc{n} = @plot; 
x{n} = 0:pi/100:(2*pi-(2*pi/100));
y{n} = abs(1./(1-(1/2).*exp(-1j*x{n}(:)))); 
xlbl{n} = '\omega'; ylbl{n} = 'H_d(\omega)'; figwidth{n} = 3.33; 
axis{n} = [-pi/4 2*pi 0 2]; ynum{n} = false;
hideyticks{n}  = false;
caption{n} = 'Desired frequency response';
n = n + 1;

fnc{n} = @stem; 
x{n} = 0:(2*pi)/N:(2*pi-(2*pi/N));
y{n} = abs(1./(1-(1/2).*exp(-1j*x{n}(:)))); 
xlbl{n} = 'k'; ylbl{n} = '|H[k]|'; figwidth{n} = 3.33; 
axis{n} = [-pi/4 2*pi 0 2]; ynum{n} = false;
hideyticks{n}  = false;
caption{n} = 'Sampled desire frequency response';
n = n + 1;

fnc{n} = @stem; 
x{n} = (0:(N-1)).'; 
kk = (1:floor((N-1)/2));
y{n} = 1/N*(y{n-1}(1) + 2*sum((-1).^kk.*y{n-1}(kk+1).'.*cos( (2*pi)./N.*(x{n} + 1/2).*kk),2 )); 
xlbl{n} = 'n'; ylbl{n} = 'h[n]'; figwidth{n} = 3.33; 
axis{n} = [-pi/4 N -max(y{n}) max(y{n})]; ynum{n} = false;
hideyticks{n}  = false;
caption{n} = 'Impulse response from sampled frequency response';
n = n + 1;

fnc{n} = @plot; 
x{n} = 0:pi/100:2*pi;
y0 = freqz(y{n-1}(x{n-1} >= 0), 1, x{n});
y{n} = [abs(1./(1-(1/2).*exp(-1j*x{n}(:)))) abs(y0(:))]; 
xlbl{n} = '\omega'; ylbl{n} = '|H_d(\omega)| and |H(\omega)|'; figwidth{n} = 3.33; 
axis{n} = [-pi/4 2*pi 0 2]; ynum{n} = false;
hideyticks{n}  = false;
caption{n} = 'Comparing true vs. desired magnitude responses';
n = n + 1;

fnc{n} = @plot; 
x{n} = 0:pi/100:2*pi;
y0 = freqz(y{n-2}(x{n-2} >= 0), 1, x{n});
y{n} = angle(y0(:)); 
xlbl{n} = '\omega'; ylbl{n} = '\angle H(\omega)'; figwidth{n} = 3.33; 
axis{n} = [-pi/4 2*pi -pi pi]; ynum{n} = false;
hideyticks{n}  = false;
caption{n} = 'Observing phase response';
n = n + 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
