function class15()
%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('../matlab/altmany-export_fig-8016f6a')
addpath('../matlab/')
namebase = ['./' ];



% SPECIFY SAMPLING INFORMATION
Ts = 0.01;      % Sampling period
Fs = 1/Ts;      % Sampling rate
ts(1) = 1/2;    % 
ts(2) = 1/2;    % 
fs = 1./ts;     % 

% SPECIFY TIME AND FREQUENCY AXES
t = (-6:Ts:(6-Ts)).'; 
N = length(t);
r = floor(N/2)+1; 
f = fftshift(ifftshift((((1:N)-r)/(N)))*Fs).'; 
df = Fs/N;

% BUILD A GAUSSIAN SIGNAL
mysignal  = @(x, delay) exp(-(x-delay).^2);

% BUILD PULSE TRAINS
pulsetrain = zeros(N,length(ts));
fpulsetrain = zeros(N,length(ts));
for m = 1:length(ts)
    pulsetrain(abs(rem(round(t/Ts), ts(m)/Ts)) < 1,m) = 1;
    pulsetrain(pulsetrain(:,1)==0,m) = nan;
    
    fpulsetrain(abs(rem(round(f/df), fs(m)/df)) < 1,m) = fs(m);
    fpulsetrain(fpulsetrain(:,1)==0,m) = nan;
end

n = 1;

%%
% ----------------------------------------
% Sampling: Continous-to-discrete
% ----------------------------------------

% What is Sampling **********
fnc{n} = @stem; 
x{n} = t; 
y{n} = nan*ones(1,length(x{n})); y{n}(~(x{n}-floor(x{n}))) = 1;
axis{n} = [-6 6 -1 1];
xlbl{n} = 't'; ylbl{n} = 'x(t)'; 
figwidth{n} = 6.66; 
marker{n} = {'^'}; markersize{n} = 6; 
caption{n} = 'Pulse train in time with $T_s = 1/2$.';
n = n + 1;

fnc{n} = @plot; 
x{n} = t; 
y{n} = sin(2*pi/10*x{n});
xlbl{n} = 't'; ylbl{n} = 'x(t)'; 
figwidth{n} = 6.66; 
axis{n} = [-6 6 -1 1]; 
caption{n} = 'Sinusoid with a period of 10.';
n = n + 1;

fnc{n} = @stem; 
x{n} = t; 
y0 = pulsetrain(:,1).*(sin(2*pi/10*x{n})+eps);
ym = y0; ym(ym > 0) = 0; ym(ym == 0) = nan;
yp = y0; yp(yp < 0) = 0; yp(yp == 0) = nan;
y{n} = [yp(:) ym(:)]; 
xlbl{n} = 't'; ylbl{n} = 'x(t)'; figwidth{n} = 6.66; 
ynum{n} = false;
hideyticks{n} = false; marker{n} = {'^', 'v'}.'; 
myColorMap{n}   = [ 79 129 189; 79 129 189 ]/255;
markersize{n} = 6; 
caption{n} = 'Sampled sinusoid with sampling period of $T_s = 1$.';
n = n + 1;


% Fourier Series/Transform of an impulse train **********
fnc{n} = @stem; 
x{n} = t; 
y{n} = pulsetrain(:,1);
xlbl{n} = 't'; ylbl{n} = 'x(t)'; figwidth{n} = 6.66; 
axis{n} = [-6 6 -1 1];
hideyticks{n} = true;
marker{n} = {'^'}; markersize{n} = 6; 
caption{n} = 'Pulse train in time with $T_s = 1/2$.';
n = n + 1;

fnc{n} = @stem; 
x{n} = f; 
y{n} = fpulsetrain(:,1);
x{n} = x{n}*2; y{n} = y{n}*2; % SINCE WE ARE IN OMEGA -- MULTIPLY BY TWO
xlbl{n} = '\Omega'; ylbl{n} = 'X(\Omega)'; figwidth{n} = 6.66; 
axis{n} = [-6 6 -4 4];
marker{n} = {'^'}; markersize{n} = 6;
ynum{n} = true;
hideyticks{n} = true; xTickSuffix{n} = '\pi'; 
xTick{n} = [-6 -4 -2 2 4 6];
yTickSuffix{n}  = '\pi';
caption{n} = 'Fourier transform of the above pulse train.';
n = n + 1;


% Apply multiplication property ************
fnc{n} = @plot; 
x{n} = t; 
y{n} = mysignal(t, 0);
xlbl{n} = 't'; ylbl{n} = 'x(t)'; figwidth{n} = 3.33; 
hideticks{n} = false; 
caption{n} = 'A Gaussian pulse signal.';
n = n + 1;

fnc{n} = @plot; 
x{n} = f*2; 
y{n} = 1/Fs*abs(fftshift(fft(mysignal(t, 0))));
xlbl{n} = '\Omega'; ylbl{n} = 'X(\Omega)'; figwidth{n} = 3.33; 
hideyticks{n} = false; xTickSuffix{n}  = '\pi'; 
xTick{n} = [-6 -4 -2 2 4 6];
axis{n} = [-10 10 0 4]; 
caption{n} = 'The Fourier transform of the above Gaussian pulse.';
n = n + 1;


fnc{n} = @stem; 
x{n} = t; 
y0 = mysignal(t, 0).*pulsetrain(:,1); 
ym = y0; ym(ym > 0) = 0; ym(ym == 0) = nan;
yp = y0; yp(yp < 0) = 0; yp(yp == 0) = nan;
y{n} = [yp(:) ym(:)];
xlbl{n} = 't'; ylbl{n} = 'x(t)'; figwidth{n} = 3.33; 
ynum{n} = false;
hideyticks{n} = false; marker{n} = {'^', 'v'}.'; 
myColorMap{n}   = [ 79 129 189; 79 129 189 ]/255;
markersize{n} = 6; 
caption{n} = 'A sampled Gaussian pulse signal with sampling period of $T_s = 1/2$ and sampling rate of $\Omega_s = 4 \pi$.';
n = n + 1;

% 9
fnc{n} = @plot; 
x{n} = f*2; 
pt = fpulsetrain(:,1); pt(isnan(pt)) = 0;
y{n} = conv(1/Fs*abs(fftshift(fft(mysignal(t, 0)))), pt, 'same');
xlbl{n} = '\Omega'; ylbl{n} = 'X(\Omega)'; figwidth{n} = 3.33; 
hideyticks{n} = false; xTickSuffix{n}  = '\pi'; 
xTick{n} = [-6 -4 -2 2 4 6];
axis{n} = [-10 10 0 4]; 
caption{n} = 'The Fourier transform the sampled Gaussian pulse with a sampling rate of $\Omega_s = 4 \pi$.';
n = n + 1;










% 
% fnc{n} = @stem; x{n} = -6:0.01:6; y{n} = nan*ones(1,length(x{n}));  
% y{n}(x{n} == 1/4) =  1/2; y{n}(x{n} == -1/4) =  1/2;
% xlbl{n} = '\Omega'; ylbl{n} = 'Y(\Omega)'; figwidth{n} = 3.33; 
% ynum{n} = true; axis{n} = [-1 1 0 0.75];
% hideticks{n} = false; marker{n} = {'^'}.'; 
% myColorMap{n}   = [ 79 129 189; ... %Blue
%                     79 129 189; ... %Blue
%                   ]/255;
% markersize{n} = 6; n = n + 1;
% 
% fnc{n} = @stem; x{n} = -6:0.01:6; y{n} = nan*ones(1,length(x{n}));  
% y{n}(x{n} == 1/4) =  1/4; y{n}(x{n} == 3/4) =  1/4;
% y{n}(x{n} == -1/4) =  1/4; y{n}(x{n} == -3/4) =  1/4;
% xlbl{n} = '\Omega'; ylbl{n} = 'Y(\Omega)'; figwidth{n} = 3.33; 
% ynum{n} = true; axis{n} = [-1 1 0 0.75];
% hideticks{n} = false; marker{n} = {'^'}.'; 
% myColorMap{n}   = [ 79 129 189; ... %Blue
%                     79 129 189; ... %Blue
%                   ]/255;
% markersize{n} = 6; n = n + 1;
% 
% 
% 
% fnc{n} = @stem; x{n} = -6:0.01:6; y{n} = nan*ones(1,length(x{n}));  
% y{n}(x{n} == 1/4) =  1/2; y{n}(x{n} == -1/4) =  1/2;
% xlbl{n} = '\Omega'; ylbl{n} = 'Y(\Omega)'; figwidth{n} = 3.33; 
% ynum{n} = true; axis{n} = [-1 1 0 0.75];
% hideticks{n} = false; marker{n} = {'^'}.'; 
% myColorMap{n}   = [ 79 129 189; ... %Blue
%                     79 129 189; ... %Blue
%                   ]/255;
% markersize{n} = 6; n = n + 1;
% 
% fnc{n} = @stem; x{n} = -6:0.005:6; y{n} = nan*ones(1,length(x{n}));  
% y{n}(x{n} == 7/8) =  1/4; y{n}(x{n} == 5/8) =  1/4;
% y{n}(x{n} == -7/8) =  1/4; y{n}(x{n} == -5/8) =  1/4;
% xlbl{n} = '\Omega'; ylbl{n} = 'Y(\Omega)'; figwidth{n} = 3.33; 
% ynum{n} = true; axis{n} = [-1 1 0 0.75];
% hideticks{n} = false; marker{n} = {'^'}.'; 
% myColorMap{n}   = [ 79 129 189; ... %Blue
%                     79 129 189; ... %Blue
%                   ]/255;
% markersize{n} = 6; n = n + 1;
% 


pltopt{n} = [];
figheight{n} = [];
axis{n} = [];
xTick{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} = [];
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}, ...
                  'caption', caption{n}, 'captionFile', [namebase 'caption' num2str(n, '%03u') '.html']);
end



end

