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


%%
% ----------------------------------------------------------------------
% TYPES OF SIGNALS
% ----------------------------------------------------------------------

% Continuous / Discrete **********
fnc{n} = @plot; x{n} = 0:.01:10;  y{n} = cos(pi/3*x{n}); 
xlbl{n} = 't'; ylbl{n} = 'x(t)'; 
caption{n} = 'Continuous-time signal';
n = n + 1;

fnc{n} = @stem; x{n} = 0:1:10;    y{n} = cos(pi/3*x{n});
hidexticks{n} = true; hideyticks{n} = true;
xlbl{n} = 'n'; ylbl{n} = 'x[n]'; 
caption{n} = 'Discrete-time signal';
n = n + 1;

% Even / Odd **********
fnc{n} = @plot; x{n} = -5:.01:5;  y{n} = exp(-x{n}.^2); 
xlbl{n} = 't'; ylbl{n} = 'x(t)'; 
caption{n} = 'Even continuous-time signal';
n = n + 1;

fnc{n} = @plot; x{n} = -5:.01:5;  y{n} = 100*diff(exp(-[x{n} nan].^2)); 
xlbl{n} = 't'; ylbl{n} = 'x(t)'; 
caption{n} = 'Odd continuous-time signal';
n = n + 1;

fnc{n} = @stem; x{n} = -5:1:5;    y{n} = [0 0 0 1 -2 3 -2 1 0 0 0]; 
hidexticks{n} = true; hideyticks{n} = true;
xlbl{n} = 'n'; ylbl{n} = 'x[n]'; 
caption{n} = 'Even discrete-time signal';
n = n + 1;

fnc{n} = @stem; x{n} = -5:1:5;    y{n} = [0 0 1 -2 0 0 0 2 -1 0 0]; 
hidexticks{n} = true; hideyticks{n} = true;
xlbl{n} = 'n'; ylbl{n} = 'x[n]'; 
caption{n} = 'Odd discrete-time signal';
n = n + 1;

% Causal / Acausal ***********
fnc{n} = @plot; x{n} = -5:.01:5;  y{n} = (x{n} > 0).*(1-exp(-x{n}.^2)); 
hidexticks{n} = true; hideyticks{n} = true;
xlbl{n} = 't'; ylbl{n} = 'x(t)'; 
caption{n} = 'Causal continuous-time signal';
n = n + 1;

fnc{n} = @plot; x{n} = -5:.01:5;  y{n} = (1-exp(-x{n}.^2)); 
hidexticks{n} = true; hideyticks{n} = true;
xlbl{n} = 't'; ylbl{n} = 'x(t)'; 
caption{n} = 'Acausal continuous-time signal';
n = n + 1;

fnc{n} = @stem; x{n} = -5:1:5;    y{n} = [0 0 0 0 0 1 1 2 1 1 0]; 
hidexticks{n} = true; hideyticks{n} = true;
xlbl{n} = 'n'; ylbl{n} = 'x[n]'; 
caption{n} = 'Causal discrete-time signal';
n = n + 1;

fnc{n} = @stem; x{n} = -5:1:5;    y{n} = [0 2 3 2 1 0 0 0 0 0 0]; 
hidexticks{n} = true; hideyticks{n} = true;
xlbl{n} = 'n'; ylbl{n} = 'x[n]'; 
caption{n} = 'Anticausal discrete-time signal';
n = n + 1;

% Periodic / Aperiodic ***********
fnc{n} = @plot; x{n} = -5:.01:5;  y{n} = cos(2*pi*x{n}); 
xlbl{n} = 't'; ylbl{n} = 'x(t)';
caption{n} = 'Periodic continuous-time signal';
n = n + 1;

fnc{n} = @stem; x{n} = 0:1:10;    y{n} = [-1 2 2 -1 2 2 -1 2 2 -1 2]; 
hidexticks{n} = true; hideyticks{n} = true;
xlbl{n} = 'n'; ylbl{n} = 'x[n]';
caption{n} = 'Periodic discrete-time signal';
n = n + 1;

%%
% ----------------------------------------------------------------------
% Measures of signal "size"
% ----------------------------------------------------------------------

% Energy *****************
fnc{n} = @plot; x{n} = -5:.01:5;  y{n} = x{n}.'.*[zeros(250, 1); ones(501, 1); zeros(250, 1)]; 
xlbl{n} = 'n'; ylbl{n} = 'x(t)'; 
caption{n} = 'Example continuous-time signal';
n = n + 1;

fnc{n} = @plot; x{n} = -5:.01:5;  y{n} = (x{n}.'.*[zeros(250, 1); ones(501, 1); zeros(250, 1)]).^2; 
xlbl{n} = 'n'; ylbl{n} = '|x(t)|^2'; 
caption{n} = 'Square of our example continuous-time signal. Integrating this signal gives the energy.';
n = n + 1;

fnc{n} = @stem; x{n} = -5:1:5;  y{n} = x{n}.*[0 0 1 1 1 1 1 1 1 0 0]; 
hidexticks{n} = true; hideyticks{n} = true;
xlbl{n} = 'n'; ylbl{n} = 'x[n]'; 
caption{n} = 'Example discrete-time signal';
n = n + 1;

fnc{n} = @stem; x{n} = -5:1:5;  y{n} = (x{n}.*[0 0 1 1 1 1 1 1 1 0 0]).^2; 
hidexticks{n} = true; hideyticks{n} = true;
xlbl{n} = 'n'; ylbl{n} = '|x[n]|^2';
caption{n} = 'Square of our example discrete-time signal. Summing this signal gives the energy.';
n = n + 1;

%%
% ----------------------------------------------------------------------
% Important Signal Operations
% ----------------------------------------------------------------------
% Time shifting ***********
fnc{n} = @plot; x{n} = -4:.01:4;  y{n} = cos(pi/4*x{n}).*(x{n} > -2).*(x{n} < 2); 
xlbl{n} = 't'; ylbl{n} = 'x(t)'; figwidth{n} = 1.5;
caption{n} = 'Example continuous-time signal';
n = n + 1;

fnc{n} = @plot; x{n} = -4:.01:4;  y{n} = cos(pi/4*(x{n}-2)).*(x{n}-2 > -2).*(x{n}-2 < 2); 
xlbl{n} = 't'; ylbl{n} = 'x(t-2)'; figwidth{n} = 1.5;
caption{n} = 'Shifted (delayed) continuous-time signal';
n = n + 1;

fnc{n} = @plot; x{n} = -4:.01:4;  y{n} = cos(pi/4*(x{n}+1)).*(x{n}+1 > -2).*(x{n}+1 < 2); 
xlbl{n} = 't'; ylbl{n} = 'x(t+1)'; figwidth{n} = 1.5; 
caption{n} = 'Shifted (advanced) continuous-time signal';
n = n + 1;

% Time scaling ***********
fnc{n} = @plot; x{n} = -4:.01:4;  y{n} = cos(pi/4*x{n}).*(x{n} > -2).*(x{n} < 2); 
xlbl{n} = 't'; ylbl{n} = 'x(t)'; figwidth{n} = 1.5;
caption{n} = 'Example continuous-time signal';
n = n + 1;

fnc{n} = @plot; x{n} = -4:.01:4;  y{n} = cos(pi/4*(x{n}/2)).*(x{n}/2 > -2).*(x{n}/2 < 2); 
xlbl{n} = 't'; ylbl{n} = 'x(t/2)'; figwidth{n} = 1.5;
caption{n} = 'Expanded continuous-time signal';
n = n + 1;

fnc{n} = @plot; x{n} = -4:.01:4;  y{n} = cos(pi/4*(x{n}*2)).*(x{n}*2 > -2).*(x{n}*2 < 2); 
xlbl{n} = 't'; ylbl{n} = 'x(2 t)'; figwidth{n} = 1.5;
caption{n} = 'Condensed continuous-time signal';
n = n + 1;

% Time reversal ***********
fnc{n} = @plot; x{n} = -5:.01:5;  y{n} = cos(pi/4*x{n}).*(x{n} > 1).*(x{n} < 3); 
xlbl{n} = 't'; ylbl{n} = 'x(t)'; 
caption{n} = 'Example continuous-time signal';
n = n + 1;

fnc{n} = @plot; x{n} = -5:.01:5;  y{n} = cos(pi/4*(-x{n})).*(-x{n} > 1).*(-x{n} < 3); 
xlbl{n} = 't'; ylbl{n} = 'x(-t)'; 
caption{n} = 'Time-reversed continuous-time signal';
n = n + 1;
%%
% ----------------------------------------------------------------------
% PERIODIC SIGNALS
% ----------------------------------------------------------------------
% 
% % The Fundamental Frequency *********
% fnc{n} = @plot; x{n} = 0:.01:40;  y{n} = cos(pi/3*x{n}); 
% xlbl{n} = 't'; ylbl{n} = 'x(t)'; n = n + 1;
% 
% fnc{n} = @plot; x{n} = 0:.01:40;  y{n} = cos(pi/4*x{n}); 
% xlbl{n} = 't'; ylbl{n} = 'x(t)'; n = n + 1;
% 
% % Computing the fundamental period for a sum of periodic signals *********
% fnc{n} = @plot; x{n} = 0:.01:100;  y{n} = cos(pi/4*x{n}) + cos(pi/3*x{n}); 
% xlbl{n} = 't'; ylbl{n} = 'x(t)'; n = n + 1;
% 
% fnc{n} = @plot; x{n} = 0:.01:4000;  y{n} = cos(2*pi/120*x{n}) + cos(2*pi/102*x{n}); 
% xlbl{n} = 't'; ylbl{n} = 'x(t)'; n = n + 1;
% 
% % Computing the fundamental frequency for a sum of periodic signals *********
% fnc{n} = @plot; x{n} = 0:.0001:0.5;  y{n} = cos(2*pi*120*x{n}) + cos(2*pi*102*x{n}); 
% xlbl{n} = 't'; ylbl{n} = 'x(t)'; n = n + 1;
% 
% fnc{n} = @plot; x{n} = 0:.0001:3;  y{n} = cos(2*pi*5*x{n}) + cos(2*pi*10*x{n}) + cos(2*pi*3*x{n}); 
% xlbl{n} = 't'; ylbl{n} = 'x(t)'; n = n + 1;


%%
% ----------------------------------------------------------------------
% SPECIAL FUNCATIONS / SIGNALS
% ----------------------------------------------------------------------

% Impulse functions **********
fnc{n} = @stem; x{n} = -10:1:10; y{n} = nan*(~isnan(x{n})); y{n}(x{n} == 0) = 1; 
hidexticks{n} = true; hideyticks{n} = true;
xlbl{n} = 't'; ylbl{n} = 'x(t)'; marker{n} = '^'; markersize{n} = 8;
caption{n} = 'Dirac delta function';
n = n + 1;

fnc{n} = @stem; x{n} = -10:1:10;  y{n} = (x{n} == 0); 
hidexticks{n} = true; hideyticks{n} = true;
xlbl{n} = 'n'; ylbl{n} = 'x[n]'; 
caption{n} = 'Kronecker delta function';
n = n + 1;

% Heaviside step functions **********
fnc{n} = @plot; x{n} = -10:0.01:10; y{n} = (x{n} >= 0); 
xlbl{n} = 't'; ylbl{n} = 'x(t)';
caption{n} = 'Continuous-time step function';
n = n + 1;

fnc{n} = @stem; x{n} = -10:1:10;  y{n} = (x{n} >= 0); 
hidexticks{n} = true; hideyticks{n} = true;
xlbl{n} = 'n'; ylbl{n} = 'x[n]'; 
caption{n} = 'Discrete-time step function';
n = n + 1;

% Cosines and sines **********
fnc{n} = @plot; x{n} = -10:.01:30;  y{n} = cos(pi/3*x{n}); 
xlbl{n} = 't'; ylbl{n} = 'x(t)';
caption{n} = 'Cosine function';
n = n + 1;

fnc{n} = @plot; x{n} = -10:.01:30;  y{n} = sin(pi/3*x{n}); 
xlbl{n} = 't'; ylbl{n} = 'x(t)'; 
caption{n} = 'Sine function';
n = n + 1;

% Stepped exponential **********
fnc{n} = @plot; x{n} = -10:0.01:30; y{n} = (x{n} >= 0).*exp(-1/5*x{n}); 
xlbl{n} = 't'; ylbl{n} = 'x(t)';
caption{n} = 'Stepped exponential function';
n = n + 1;

% Complex exponentials **********
fnc{n} = @plot; x{n} = -10:0.01:30; y{n} = [cos(pi/3*x{n}).' sin(pi/3*x{n}).']; 
xlbl{n} = 't'; ylbl{n} = 'x(t)';
caption{n} = 'Complex exponential function (blue = real part, red = imaginary part)';
n = n + 1;

% Stepped general exponential **********
fnc{n} = @plot; x{n} = -10:0.01:30; y{n} = [cos(pi/3*x{n}).'.*(x{n}.' >= 0).*exp(-1/5*x{n}.') sin(pi/3*x{n}).'.*(x{n}.' >= 0).*exp(-1/5*x{n}.')]; 
xlbl{n} = 't'; ylbl{n} = 'x(t)';
caption{n} = 'Stepped complex exponential function (blue = real part, red = imaginary part)';
n = n + 1;

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


end

