Deprecated: Function create_function() is deprecated in /home/c00p/www/lib/geshi/geshi.php on line 4698
function avg_summary()
%--------------------------------------------------------------------------
% Average Spectrum Error Summary
%
% Cooper Baker - 2014
%--------------------------------------------------------------------------

close all;

name = 'Average Spectrum Summary';

% set path
p = genpath( '../../analyze' );
addpath( p );

% algorithm names for plot labels
algos = { 'Classic', 'Lock', 'Peak', 'Bank', 'Sola', 'Ola' };

% file names for plot labels
fileAname = 'Sine';
fileBname = 'Square';
fileCname = 'Sweep';
fileDname = 'Amen';
fileEname = 'Autumn';
fileFname = 'Peaches';

% file names for csvread
fileA = 'sine';
fileB = 'square';
fileC = 'sweep';
fileD = 'amen';
fileE = 'autumn';
fileF = 'peaches';

% read the error plot data
rawAdata = csvread( [ fileA, '.classic.avg.err.csv' ] );
rawBdata = csvread( [ fileB, '.classic.avg.err.csv' ] );
rawCdata = csvread( [ fileC, '.classic.avg.err.csv' ] );
rawDdata = csvread( [ fileD, '.classic.avg.err.csv' ] );
rawEdata = csvread( [ fileE, '.classic.avg.err.csv' ] );
rawFdata = csvread( [ fileF, '.classic.avg.err.csv' ] );

lockAdata = csvread( [ fileA, '.lock.avg.err.csv' ] );
lockBdata = csvread( [ fileB, '.lock.avg.err.csv' ] );
lockCdata = csvread( [ fileC, '.lock.avg.err.csv' ] );
lockDdata = csvread( [ fileD, '.lock.avg.err.csv' ] );
lockEdata = csvread( [ fileE, '.lock.avg.err.csv' ] );
lockFdata = csvread( [ fileF, '.lock.avg.err.csv' ] );

peakAdata = csvread( [ fileA, '.peak.avg.err.csv' ] );
peakBdata = csvread( [ fileB, '.peak.avg.err.csv' ] );
peakCdata = csvread( [ fileC, '.peak.avg.err.csv' ] );
peakDdata = csvread( [ fileD, '.peak.avg.err.csv' ] );
peakEdata = csvread( [ fileE, '.peak.avg.err.csv' ] );
peakFdata = csvread( [ fileF, '.peak.avg.err.csv' ] );

bankAdata = csvread( [ fileA, '.bank.avg.err.csv' ] );
bankBdata = csvread( [ fileB, '.bank.avg.err.csv' ] );
bankCdata = csvread( [ fileC, '.bank.avg.err.csv' ] );
bankDdata = csvread( [ fileD, '.bank.avg.err.csv' ] );
bankEdata = csvread( [ fileE, '.bank.avg.err.csv' ] );
bankFdata = csvread( [ fileF, '.bank.avg.err.csv' ] );

solaAdata = csvread( [ fileA, '.sola.avg.err.csv' ] );
solaBdata = csvread( [ fileB, '.sola.avg.err.csv' ] );
solaCdata = csvread( [ fileC, '.sola.avg.err.csv' ] );
solaDdata = csvread( [ fileD, '.sola.avg.err.csv' ] );
solaEdata = csvread( [ fileE, '.sola.avg.err.csv' ] );
solaFdata = csvread( [ fileF, '.sola.avg.err.csv' ] );

olaAdata = csvread( [ fileA, '.ola.avg.err.csv' ] );
olaBdata = csvread( [ fileB, '.ola.avg.err.csv' ] );
olaCdata = csvread( [ fileC, '.ola.avg.err.csv' ] );
olaDdata = csvread( [ fileD, '.ola.avg.err.csv' ] );
olaEdata = csvread( [ fileE, '.ola.avg.err.csv' ] );
olaFdata = csvread( [ fileF, '.ola.avg.err.csv' ] );

% find max values
rawAmax = max( rawAdata );
rawBmax = max( rawBdata );
rawCmax = max( rawCdata );
rawDmax = max( rawDdata );
rawEmax = max( rawEdata );
rawFmax = max( rawFdata );

lockAmax = max( lockAdata );
lockBmax = max( lockBdata );
lockCmax = max( lockCdata );
lockDmax = max( lockDdata );
lockEmax = max( lockEdata );
lockFmax = max( lockFdata );

lockAavg = sum( lockAdata ) / length( lockAdata );
lockBavg = sum( lockBdata ) / length( lockBdata );
lockCavg = sum( lockCdata ) / length( lockCdata );
lockDavg = sum( lockDdata ) / length( lockDdata );
lockEavg = sum( lockEdata ) / length( lockEdata );
lockFavg = sum( lockFdata ) / length( lockFdata );

peakAmax = max( peakAdata );
peakBmax = max( peakBdata );
peakCmax = max( peakCdata );
peakDmax = max( peakDdata );
peakEmax = max( peakEdata );
peakFmax = max( peakFdata );

bankAmax = max( bankAdata );
bankBmax = max( bankBdata );
bankCmax = max( bankCdata );
bankDmax = max( bankDdata );
bankEmax = max( bankEdata );
bankFmax = max( bankFdata );

solaAmax = max( solaAdata );
solaBmax = max( solaBdata );
solaCmax = max( solaCdata );
solaDmax = max( solaDdata );
solaEmax = max( solaEdata );
solaFmax = max( solaFdata );

olaAmax = max( olaAdata );
olaBmax = max( olaBdata );
olaCmax = max( olaCdata );
olaDmax = max( olaDdata );
olaEmax = max( olaEdata );
olaFmax = max( olaFdata );

% calculate averages
rawAavg = sum( rawAdata ) / length( rawAdata );
rawBavg = sum( rawBdata ) / length( rawBdata );
rawCavg = sum( rawCdata ) / length( rawCdata );
rawDavg = sum( rawDdata ) / length( rawDdata );
rawEavg = sum( rawEdata ) / length( rawEdata );
rawFavg = sum( rawFdata ) / length( rawFdata );

peakAavg = sum( peakAdata ) / length( peakAdata );
peakBavg = sum( peakBdata ) / length( peakBdata );
peakCavg = sum( peakCdata ) / length( peakCdata );
peakDavg = sum( peakDdata ) / length( peakDdata );
peakEavg = sum( peakEdata ) / length( peakEdata );
peakFavg = sum( peakFdata ) / length( peakFdata );

bankAavg = sum( bankAdata ) / length( bankAdata );
bankBavg = sum( bankBdata ) / length( bankBdata );
bankCavg = sum( bankCdata ) / length( bankCdata );
bankDavg = sum( bankDdata ) / length( bankDdata );
bankEavg = sum( bankEdata ) / length( bankEdata );
bankFavg = sum( bankFdata ) / length( bankFdata );

solaAavg = sum( solaAdata ) / length( solaAdata );
solaBavg = sum( solaBdata ) / length( solaBdata );
solaCavg = sum( solaCdata ) / length( solaCdata );
solaDavg = sum( solaDdata ) / length( solaDdata );
solaEavg = sum( solaEdata ) / length( solaEdata );
solaFavg = sum( solaFdata ) / length( solaFdata );

olaAavg = sum( olaAdata ) / length( olaAdata );
olaBavg = sum( olaBdata ) / length( olaBdata );
olaCavg = sum( olaCdata ) / length( olaCdata );
olaDavg = sum( olaDdata ) / length( olaDdata );
olaEavg = sum( olaEdata ) / length( olaEdata );
olaFavg = sum( olaFdata ) / length( olaFdata );

% find max of each audio file
maxAmax = max( [ rawAmax lockAmax peakAmax bankAmax solaAmax olaAmax ] );
maxBmax = max( [ rawBmax lockBmax peakBmax bankBmax solaBmax olaBmax ] );
maxCmax = max( [ rawCmax lockCmax peakCmax bankCmax solaCmax olaCmax ] );
maxDmax = max( [ rawDmax lockDmax peakDmax bankDmax solaDmax olaDmax ] );
maxEmax = max( [ rawEmax lockEmax peakEmax bankEmax solaEmax olaEmax ] );
maxFmax = max( [ rawFmax lockFmax peakFmax bankFmax solaFmax olaFmax ] );

% create matricies of max values for plots
maxA = [ rawAmax lockAmax peakAmax bankAmax solaAmax olaAmax ];
maxB = [ rawBmax lockBmax peakBmax bankBmax solaBmax olaBmax ];
maxC = [ rawCmax lockCmax peakCmax bankCmax solaCmax olaCmax ];
maxD = [ rawDmax lockDmax peakDmax bankDmax solaDmax olaDmax ];
maxE = [ rawEmax lockEmax peakEmax bankEmax solaEmax olaEmax ];
maxF = [ rawFmax lockFmax peakFmax bankFmax solaFmax olaFmax ];

% create matrices of avg values for plots
avgA = [ rawAavg lockAavg peakAavg bankAavg solaAavg olaAavg ];
avgB = [ rawBavg lockBavg peakBavg bankBavg solaBavg olaBavg ];
avgC = [ rawCavg lockCavg peakCavg bankCavg solaCavg olaCavg ];
avgD = [ rawDavg lockDavg peakDavg bankDavg solaDavg olaDavg ];
avgE = [ rawEavg lockEavg peakEavg bankEavg solaEavg olaEavg ];
avgF = [ rawFavg lockFavg peakFavg bankFavg solaFavg olaFavg ];

% Plot
%--------------------------------------------------------------------------

% graph formatting
fontName   = 'Times New Roman';
fontSize   = 12;
xTxt = 0.125;
yTxt = 1.2;
yOff = 0.13;

% set up plot window
fig = figure( 1 );
set( fig, 'Name', sprintf( '%s', name ) );
set( fig, 'Position', [ 0 0 800 1000 ] );
set( fig, 'defaultAxesFontName', fontName );
set( fig, 'defaultTextFontName', fontName );
set( fig, 'defaultaxescolororder', [ 0.8 0.2 0.2 ] );

% fileA
%--------------------------------------------------------------------------
plotL = avgA;
plotR = maxA;
fileName = fileAname;
sp = subplot( 6, 2, 1 );
bar( plotL, 'FaceColor', [ 0.8 0.2 0.2 ] );
set( sp, 'Position', [ 0.1, 5.5/7, 0.39, 1/7.333 ] );
axis( [ 0 7 0 ( maxAmax * 1.3 ) ] );
for( i = 1 : 6 )
    text( i, plotL( i ) + maxAmax * yOff, num2str( plotL( i ), '%2.5f' ), 'HorizontalAlignment', 'center', 'BackgroundColor', 'w', 'EdgeColor', 'k', 'FontSize', 9 );
end
set( gca, 'TickLength', [ 0 0 ] );
set( gca, 'YGrid', 'on', 'XGrid', 'off' );
set( gca, 'XTickLabel', [] );
temp = get( gca );
yticks = get( gca, 'YTick' );
set( gca, 'YTickLabel', yticks );
text( xTxt, yTxt * maxAmax, [ ' ' fileName ' ' ], 'BackgroundColor', 'w', 'EdgeColor', 'k' );
title( 'Average', 'FontSize', fontSize );

sp = subplot( 6, 2, 2 );
bar( plotR, 'FaceColor', [ 0.8 0.2 0.2 ] );
set( sp, 'Position', [ 0.5, 5.5/7, 0.39, 1/7.333 ] );
axis( [ 0 7 0 ( maxAmax * 1.3 ) ] );
for( i = 1 : 6 )
    text( i, plotR( i ) + maxAmax * yOff, num2str( plotR( i ), '%2.5f' ), 'HorizontalAlignment', 'center', 'BackgroundColor', 'w', 'EdgeColor', 'k', 'FontSize', 9 );
end
set( gca, 'TickLength', [ 0 0 ] );
set( gca, 'YGrid', 'on', 'XGrid', 'off' );
set( gca, 'XTickLabel', [] );
set( gca, 'YTickLabel', [] );
title( 'Maximum', 'FontSize', fontSize );

% fileB
%--------------------------------------------------------------------------
plotL = avgB;
plotR = maxB;
fileName = fileBname;
sp = subplot( 6, 2, 3 );
bar( plotL, 'FaceColor', [ 0.8 0.2 0.2 ] );
set( sp, 'Position', [ 0.1, 4.5/7, 0.39, 1/7.333 ] );
axis( [ 0 7 0 ( maxBmax * 1.3 ) ] );
for( i = 1 : 6 )
    text( i, plotL( i ) + maxBmax * yOff, num2str( plotL( i ), '%2.5f' ), 'HorizontalAlignment', 'center', 'BackgroundColor', 'w', 'EdgeColor', 'k', 'FontSize', 9 );
end
set( gca, 'TickLength', [ 0 0 ] );
set( gca, 'YGrid', 'on', 'XGrid', 'off' );
set( gca, 'XTickLabel', [] );
temp = get( gca );
yticks = get( gca, 'YTick' );
set( gca, 'YTickLabel', yticks );
text( xTxt, yTxt * maxBmax, [ ' ' fileName ' ' ], 'BackgroundColor', 'w', 'EdgeColor', 'k' );

sp = subplot( 6, 2, 4 );
bar( plotR, 'FaceColor', [ 0.8 0.2 0.2 ] );
set( sp, 'Position', [ 0.5, 4.5/7, 0.39, 1/7.333 ] );
axis( [ 0 7 0 ( maxBmax * 1.3 ) ] );
for( i = 1 : 6 )
    text( i, plotR( i ) + maxBmax * yOff, num2str( plotR( i ), '%2.5f' ), 'HorizontalAlignment', 'center', 'BackgroundColor', 'w', 'EdgeColor', 'k', 'FontSize', 9 );
end
set( gca, 'TickLength', [ 0 0 ] );
set( gca, 'YGrid', 'on', 'XGrid', 'off' );
set( gca, 'XTickLabel', [] );
set( gca, 'YTickLabel', [] );

% fileC
%--------------------------------------------------------------------------
plotL = avgC;
plotR = maxC;
fileName = fileCname;
sp = subplot( 6, 2, 5 );
bar( plotL, 'FaceColor', [ 0.8 0.2 0.2 ] );
set( sp, 'Position', [ 0.1, 3.5/7, 0.39, 1/7.333 ] );
axis( [ 0 7 0 ( maxCmax * 1.3 ) ] );
for( i = 1 : 6 )
    text( i, plotL( i ) + maxCmax * yOff, num2str( plotL( i ), '%2.5f' ), 'HorizontalAlignment', 'center', 'BackgroundColor', 'w', 'EdgeColor', 'k', 'FontSize', 9 );
end
set( gca, 'TickLength', [ 0 0 ] );
set( gca, 'YGrid', 'on', 'XGrid', 'off' );
set( gca, 'XTickLabel', [] );
temp = get( gca );
yticks = get( gca, 'YTick' );
set( gca, 'YTickLabel', yticks );
text( xTxt, yTxt * maxCmax, [ ' ' fileName ' ' ], 'BackgroundColor', 'w', 'EdgeColor', 'k' );

sp = subplot( 6, 2, 6 );
bar( plotR, 'FaceColor', [ 0.8 0.2 0.2 ] );
set( sp, 'Position', [ 0.5, 3.5/7, 0.39, 1/7.333 ] );
axis( [ 0 7 0 ( maxCmax * 1.3 ) ] );
for( i = 1 : 6 )
    text( i, plotR( i ) + maxCmax * yOff, num2str( plotR( i ), '%2.5f' ), 'HorizontalAlignment', 'center', 'BackgroundColor', 'w', 'EdgeColor', 'k', 'FontSize', 9 );
end
set( gca, 'TickLength', [ 0 0 ] );
set( gca, 'YGrid', 'on', 'XGrid', 'off' );
set( gca, 'XTickLabel', [] );
set( gca, 'YTickLabel', [] );

% fileD
%--------------------------------------------------------------------------
plotL = avgD;
plotR = maxD;
fileName = fileDname;
sp = subplot( 6, 2, 7 );
bar( plotL, 'FaceColor', [ 0.8 0.2 0.2 ] );
set( sp, 'Position', [ 0.1, 2.5/7, 0.39, 1/7.333 ] );
axis( [ 0 7 0 ( maxDmax * 1.3 ) ] );
for( i = 1 : 6 )
    text( i, plotL( i ) + maxDmax * yOff, num2str( plotL( i ), '%2.5f' ), 'HorizontalAlignment', 'center', 'BackgroundColor', 'w', 'EdgeColor', 'k', 'FontSize', 9 );
end
set( gca, 'TickLength', [ 0 0 ] );
set( gca, 'YGrid', 'on', 'XGrid', 'off' );
set( gca, 'XTickLabel', [] );
temp = get( gca );
yticks = get( gca, 'YTick' );
set( gca, 'YTickLabel', yticks );
text( xTxt, yTxt * maxDmax, [ ' ' fileName ' ' ], 'BackgroundColor', 'w', 'EdgeColor', 'k' );

sp = subplot( 6, 2, 8 );
bar( plotR, 'FaceColor', [ 0.8 0.2 0.2 ] );
set( sp, 'Position', [ 0.5, 2.5/7, 0.39, 1/7.333 ] );
axis( [ 0 7 0 ( maxDmax * 1.3 ) ] );
for( i = 1 : 6 )
    text( i, plotR( i ) + maxDmax * yOff, num2str( plotR( i ), '%2.5f' ), 'HorizontalAlignment', 'center', 'BackgroundColor', 'w', 'EdgeColor', 'k', 'FontSize', 9 );
end
set( gca, 'TickLength', [ 0 0 ] );
set( gca, 'YGrid', 'on', 'XGrid', 'off' );
set( gca, 'XTickLabel', [] );
set( gca, 'YTickLabel', [] );

% fileE
%--------------------------------------------------------------------------
plotL = avgE;
plotR = maxE;
fileName = fileEname;
sp = subplot( 6, 2, 9 );
bar( plotL, 'FaceColor', [ 0.8 0.2 0.2 ] );
set( sp, 'Position', [ 0.1, 1.5/7, 0.39, 1/7.333 ] );
axis( [ 0 7 0 ( maxEmax * 1.3 ) ] );
for( i = 1 : 6 )
    text( i, plotL( i ) + maxEmax * yOff, num2str( plotL( i ), '%2.5f' ), 'HorizontalAlignment', 'center', 'BackgroundColor', 'w', 'EdgeColor', 'k', 'FontSize', 9 );
end
set( gca, 'TickLength', [ 0 0 ] );
set( gca, 'YGrid', 'on', 'XGrid', 'off' );
set( gca, 'XTickLabel', [] );
temp = get( gca );
yticks = get( gca, 'YTick' );
set( gca, 'YTickLabel', yticks );
text( xTxt, yTxt * maxEmax, [ ' ' fileName ' ' ], 'BackgroundColor', 'w', 'EdgeColor', 'k' );

sp = subplot( 6, 2, 10 );
bar( plotR, 'FaceColor', [ 0.8 0.2 0.2 ] );
set( sp, 'Position', [ 0.5, 1.5/7, 0.39, 1/7.333 ] );
axis( [ 0 7 0 ( maxEmax * 1.3 ) ] );
for( i = 1 : 6 )
    text( i, plotR( i ) + maxEmax * yOff, num2str( plotR( i ), '%2.5f' ), 'HorizontalAlignment', 'center', 'BackgroundColor', 'w', 'EdgeColor', 'k', 'FontSize', 9 );
end
set( gca, 'TickLength', [ 0 0 ] );
set( gca, 'YGrid', 'on', 'XGrid', 'off' );
set( gca, 'XTickLabel', [] );
set( gca, 'YTickLabel', [] );

% fileF
%--------------------------------------------------------------------------
plotL = avgF;
plotR = maxF;
fileName = fileFname;
sp = subplot( 6, 2, 11 );
bar( plotL, 'FaceColor', [ 0.8 0.2 0.2 ] );
set( sp, 'Position', [ 0.1, 0.5/7, 0.39, 1/7.333 ] );
axis( [ 0 7 0 ( maxFmax * 1.3 ) ] );
for( i = 1 : 6 )
    text( i, plotL( i ) + maxFmax * yOff, num2str( plotL( i ), '%2.5f' ), 'HorizontalAlignment', 'center', 'BackgroundColor', 'w', 'EdgeColor', 'k', 'FontSize', 9 );
end
set( gca, 'TickLength', [ 0 0 ] );
set( gca, 'YGrid', 'on', 'XGrid', 'off' );
set( gca, 'XTickLabel', algos );
temp = get( gca );
yticks = get( gca, 'YTick' );
set( gca, 'YTickLabel', yticks );
yLab = ylabel( 'Sones' );
text( xTxt, yTxt * maxFmax, [ ' ' fileName ' ' ], 'BackgroundColor', 'w', 'EdgeColor', 'k' );

sp = subplot( 6, 2, 12 );
bar( plotR, 'FaceColor', [ 0.8 0.2 0.2 ] );
set( sp, 'Position', [ 0.5, 0.5/7, 0.39, 1/7.333 ] );
axis( [ 0 7 0 ( maxFmax * 1.3 ) ] );
for( i = 1 : 6 )
    text( i, plotR( i ) + maxFmax * yOff, num2str( plotR( i ), '%2.5f' ), 'HorizontalAlignment', 'center', 'BackgroundColor', 'w', 'EdgeColor', 'k', 'FontSize', 9 );
end
set( gca, 'TickLength', [ 0 0 ] );
set( gca, 'XTickLabel', algos );
set( gca, 'YTickLabel', [] );
set( gca, 'YGrid', 'on', 'XGrid', 'off' );
xLab = xlabel( 'Algorithms' );

% tighten up figure borders
tightfig();

% move x and y labels
set( xLab, 'Position', [ -0.1 ( maxFmax * -0.16 ) ] );
set( yLab, 'Position', [ -0.625 ( ( maxFmax * 1.3 * 6.25 ) / 2 ) ] );

% write plot to file
hgexport( fig, [ 'summary.avg.eps' ] );

% EOF