%   Name: mcdisp
%
%   Usage: mcdisp
%
%   Description: Displays the results of a monte carlo analysis
%
     
%
%  Version SWD970619
%
%  Author(s): Scott W. Doebling, doebling@lanl.gov
%
%  Institution: Los Alamos National Laboratory,
%		ESA-EA
%
%  Copyright (c) 1997, The Regents of the University
%     	of California. (See top level of code for
%		full copyright statement.)

%
%  Build string of frequency statistics
%

freqstr = sprintf('%7s%13s%15s%15s %1s','Mode #','Mean (Hz)','Abs 2Sig (Hz)','Rel 2Sig (%)','|');

for i=1:size(Freqallnew,1)
   mfrq(i) = mean(Freqallnew(i,:));
   std2frqabs(i) = 2*std(Freqallnew(i,:));
   std2frqrel(i) = std2frqabs(i) / mfrq(i);
   freqstr = [freqstr, sprintf('%7i   %0.3e  %0.3e      %0.3e %1s',...
         i,mfrq(i),std2frqabs(i),std2frqrel(i)*100,'|')];
end

%
%  Build string of damping statistics
%

dampstr = sprintf('%7s%13s%15s%15s %1s','Mode #','Mean (%)','Abs 2Sig (%)','Rel 2Sig (%)','|');

for i=1:size(Dampallnew,1)
   
   mdamp(i) = mean(Dampallnew(i,:));
   std2dmpabs(i) = 2*std(Dampallnew(i,:));
   std2dmprel(i) = std2dmpabs(i) / mdamp(i);
   dampstr = [dampstr, sprintf('%7i   %0.3e   %0.3e     %0.3e %1s',...
         i,mdamp(i)*100,std2dmpabs(i)*100,std2dmprel(i)*100,'|')];
   
end

%
%  Initialize variables
%

if ~exist('nmciter'), nmciter = 1; end
if ~exist('imcanal'), imcanal = 0; end


hmcdisp(1) = figure('units','normal','position',[0.05 0.1 0.9 0.5],...
			'menubar','none','numbertitle','off','resize','on',...
			'name','Diamond: Monte Carlo Analysis Results');

top=.95;
left=.05;
btnwd=.75;
btnht=.1;
spacing=.01;

%
%  Close (no store) Button
%

btnpos = [0.7 0.05 0.2 0.1];
hmcdisp(2) = uicontrol(hmcdisp(1),...
	'style','push',...
	'position',btnpos,...
	'string','Close',...
   'call','delete(hmcdisp(1))');

%
%  Store Button
%

btnpos = [0.48 0.05 0.2 0.1];
hmcdisp(5) = uicontrol(hmcdisp(1),...
	'style','push',...
	'position',btnpos,...
	'string','Store Results',...
   'call',['Freq = [Freq; mean(Freqallnew'')'']; ',...
      'Damp = [Damp; mean(Dampallnew'')'']; ',...
      'for i = 1:size(Phicrespallnew,3),',...
      '   phic_resp = [phic_resp , mean(Phicrespallnew(:,:,i).'').'']; ',...
      '   phic_ref  = [phic_ref  , mean(Phicrefallnew(:,:,i).'').'']; ',...
      'end,',...
      'Freqall = [Freqall; Freqallnew]; ',...
      'Dampall = [Dampall; Dampallnew]; ',...
      'if exist(''Phicrespall'')~=1, Phicrespall = []; Phicrefall = []; nmodtemp=0;',...
      ' else,  nmodtemp = size(Phicrespall,3); end,',...
      'nmodnew = size(Phicrespallnew,3); ',...
      'Phicrespall(:,:,[nmodtemp+1 : nmodtemp + nmodnew]) = Phicrespallnew; ',...
      'Phicrefall(:,:,[nmodtemp+1 : nmodtemp + nmodnew]) = Phicrefallnew; ',...
      'set(hmmenu(6),''enable'',''on''),',...
      'delete(hmcdisp(1))']);

%
%  Listboxes of Statistics
%

hmcdisp(3) = uicontrol(hmcdisp(1),...
   'style','listbox',...
   'position',[0.05 0.65 0.9 0.3],...
   'fontname','courier',...
   'string',freqstr);

uicontrol(hmcdisp(1),...
   'style','text',...
   'position',[0.10 0.95 0.20 0.05],...
   'fontname','Courier',...
   'string','Frequency (Hz)');
   
hmcdisp(4) = uicontrol(hmcdisp(1),...
   'style','listbox',...
   'position',[0.05 0.25 0.9 0.3],...
   'fontname','courier',...
   'string',dampstr);

uicontrol(hmcdisp(1),...
   'style','text',...
   'position',[0.10 0.55 0.20 0.05],...
   'fontname','Courier',...
   'string','Damping Ratio (%)');
   