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




n = 1;

% APPROXIMATION

Ts = 1/10;

sys = tf(1,[1 0]);
[num,den] = tfdata(sys);

sysz = zpk(0,[1],Ts,Ts); 
[numz,denz] = tfdata(sysz);

w = ((1/Ts)/2*2*pi)/1000:((1/Ts)/2*2*pi)/1000:((1/Ts)/2*2*pi);
wz = pi/1002:pi/1000:(2*pi);
w0 = (2*pi/10)/1000:(2*pi/10)/1000:(2*pi/10);

fnc{n} = @plot;
[y{n}, x{n}] = freqz(numz{1},denz{1},wz); 
y{n} = abs(y{n});
xlbl{n} = '\omega'; ylbl{n} = '|H(\omega)|'; figwidth{n} = 2.4; 
hidexticks{n} = false; axis{n} = [-max(x{n})/8 max(x{n}) 0 1];
caption{n} = 'Designed IIR frequency magnitude response';
n = n + 1;

fnc{n} = @stem;
x{n} = 0:20;
y{n} = filter(numz{1},denz{1}, [1; zeros(20,1)]);
xlbl{n} = 'n'; ylbl{n} = 'h[n]'; figwidth{n} = 2.4; 
hidexticks{n}  = true; ynum{n} = false; hideyticks{n}  = false; 
axis{n} = [-5 20 -max(abs(y{n})) max(abs(y{n}))]; yTick{n} = [-max(abs(y{n})) max(abs(y{n}))];
caption{n} = 'Designed IIR impulse response';
n = n + 1;

fnc{n} = @plot;
[y{n}, x{n}] = freqs(num{1},den{1},w); 
[y0, x0] = freqz(numz{1},denz{1},1000,1/Ts); 
y{n} = [abs(y{n}(:)) abs(y0(:))];
xlbl{n} = '\Omega'; ylbl{n} = '|H_d(\Omega)| and |H(\omega f_s)|'; figwidth{n} = 2.4; 
hidexticks{n} = false; axis{n} = [-max(x{n})/8 max(x{n}) 0 1];
caption{n} = 'Comparison between true [designed] and desired magnitude responses';
n = n + 1;






% IMPULSE INVARIANCE

Ts = 1/10;

sys = tf(1,[1 0]);
[num,den] = tfdata(sys);

sysz = zpk(0,[1],1,Ts); 
[numz,denz] = tfdata(sysz);
numz{1} = numz{1}*Ts;

w = ((1/Ts)/2*2*pi)/1000:((1/Ts)/2*2*pi)/1000:((1/Ts)/2*2*pi);
wz = pi/1002:pi/1000:(2*pi);
w0 = (2*pi/10)/1000:(2*pi/10)/1000:(2*pi/10);

fnc{n} = @plot;
[y{n}, x{n}] = freqz(numz{1},denz{1},wz); 
y{n} = abs(y{n});
xlbl{n} = '\omega'; ylbl{n} = '|H(\omega)|'; figwidth{n} = 2.4; 
hidexticks{n} = false; axis{n} = [-max(x{n})/8 max(x{n}) 0 1];
caption{n} = 'Designed IIR frequency magnitude response';
n = n + 1;

fnc{n} = @stem;
x{n} = 0:20;
y{n} = filter(numz{1},denz{1}, [1; zeros(20,1)]);
xlbl{n} = 'n'; ylbl{n} = 'h[n]'; figwidth{n} = 2.4; 
hidexticks{n}  = true; ynum{n} = false; hideyticks{n}  = false; 
axis{n} = [-5 20 -max(abs(y{n})) max(abs(y{n}))]; yTick{n} = [-max(abs(y{n})) max(abs(y{n}))];
caption{n} = 'Designed IIR impulse response';
n = n + 1;

fnc{n} = @plot;
[y{n}, x{n}] = freqs(num{1},den{1},w); 
[y0, x0] = freqz(numz{1},denz{1},1000,1/Ts); 
y{n} = [abs(y{n}(:)) abs(y0(:))];
xlbl{n} = '\Omega'; ylbl{n} = '|H_d(\Omega)| and |H(\omega f_s)|'; figwidth{n} = 2.4; 
hidexticks{n} = false; axis{n} = [-max(x{n})/8 max(x{n}) 0 1];
caption{n} = 'Comparison between true [designed] and desired magnitude responses';
n = n + 1;







% LAPLACE TRANSFORM

Ts = 1/10;

sys = tf(1,[1 0]);
[num,den] = tfdata(sys);

sysz = zpk([-1],[1],Ts/2,Ts); 
[numz,denz] = tfdata(sysz);

w = ((1/Ts)/2*2*pi)/1000:((1/Ts)/2*2*pi)/1000:((1/Ts)/2*2*pi);
wz = pi/1002:pi/1000:(2*pi);
w0 = (2*pi/10)/1000:(2*pi/10)/1000:(2*pi/10);

fnc{n} = @plot;
[y{n}, x{n}] = freqz(numz{1},denz{1},wz); 
y{n} = abs(y{n});
xlbl{n} = '\omega'; ylbl{n} = '|H(\omega)|'; figwidth{n} = 2.4; 
hidexticks{n} = false; axis{n} = [-max(x{n})/8 max(x{n}) 0 1];
caption{n} = 'Designed IIR frequency magnitude response';
n = n + 1;

fnc{n} = @stem;
x{n} = 0:20;
y{n} = filter(numz{1},denz{1}, [1; zeros(20,1)]);
xlbl{n} = 'n'; ylbl{n} = 'h[n]'; figwidth{n} = 2.4; 
hidexticks{n}  = true; ynum{n} = false; hideyticks{n}  = false; 
axis{n} = [-5 20 -max(abs(y{n})) max(abs(y{n}))]; yTick{n} = [-max(abs(y{n})) max(abs(y{n}))];
caption{n} = 'Designed IIR impulse response';
n = n + 1;

fnc{n} = @plot;
[y{n}, x{n}] = freqs(num{1},den{1},w); 
[y0, x0] = freqz(numz{1},denz{1},1000,1/Ts); 
y{n} = [abs(y{n}(:)) abs(y0(:))];
xlbl{n} = '\Omega'; ylbl{n} = '|H_d(\Omega)| and |H(\omega f_s)|'; figwidth{n} = 2.4; 
hidexticks{n} = false; axis{n} = [-max(x{n})/8 max(x{n}) 0 1];
caption{n} = 'Comparison between true [designed] and desired magnitude responses';
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
