function  LabBM_SL_05(filename1,filename2)
% -------------------------------------------------------------------------
%               NTHMP (National Tsunami Hazard Mitigation Program)
% -------------------------------------------------------------------------
%                          2010 NTHMP WORKSHOP
%              Venue: TBA (Catalina Island, CA;
%                     Santa Monica, CA; Irvine, CA; Corvallis, OR;
%                     Boulder, CO.
%                            NOV. 16th-18th 2010
%                               ---- o ----
%               MATLAB SCRIPT:  Tsunami Generation and Runup due to
%                               Three-dimensional Landslide
%               TYPE:           Laboratory Benchmarking (LabBM)
%                               NUMBER: 05
%               TSUNAMI SOURCE: Submarine Landslide (SL)                       
%               SCRIPT NAME   : LabBM_SL_05.m
%                
%               AUTHOR(S)     : D. Nicolsky, C. Synolakis, S Grilli
%                               and J. Horrillo.
%   	        
%                              Copyright 2010 NTHMP/NOAA
%                              Revision: 0
%                              Date: Sep/2010
%               REFERENCE:
%                   Synolakis, C.E., E.N. Bernard, V.V. Titov, U. Kâno?lu,
%               and F.I. González (2007): Standards, criteria, and
%               procedures for NOAA evaluation of tsunami numerical models.
%               NOAA Tech. Memo. OAR PMEL-135, NOAA/Pacific Marine
%               Environmental Laboratory, Seattle, WA, 55 pp.
% 
%                   NOAA/PMEL Center for Tsunami research
%               http://nctr.pmel.noaa.gov/benchmark/index.html
% 
%                   Liu, P.L.-F., T.-R. Wu, F. Raichlen, C.E. Synolakis,
%               and J. Borrero (2005): Runup and rundown generated
%               by three-dimensional sliding masses. J. Fluid Mech.,
%               536, 107-144. 
% 
%                   Liu, P.L.-F., H. Yeh, and C. Synolakis (2008): Advanced
%               Numerical Models for Simulating Tsunami Waves and Runup.
%               Advances in Coastal and Ocean Engineering, 10, 250 pp. 
% 
%               INCLUDED FILES WITH THIS SCRIPT: 
%               SL_05_025.mat (lab. data file  Delta= 2.5cm)
%               SL_05_100.mat (lab. data file  Delta=10.0cm)
%               Note: Above files are needed to run successfully this
%                     script.
% 
%               CONTACT INFO:   Dr. Juan J. Horrillo, 
%                               Texas A&M University at Galveston 
%                               Maritime Systems Engineering (MASE) 
%                               200 Seawolf Park or P.O. Box 1675 
%                               Galveston, TX  77553-1675 
%                               Phone: (409) 740-4465
%                               horrillj@tamug.edu
%                               Website: http://www.tamug.edu/
% 
% -------------------------------------------------------------------------
%   > LabBM_SL_05(filename1,filename2)
%
%   LabBM_SL_05 reads input files 'filename1' and 'filename2' containing 
%   model results and compares them with laboratory data described
%   in the Benchmark "Tsunami Generation and Runup due to Three-dimensional
%   landslide", NOAA/PMEL, (http://nctr.pmel.noaa.gov/benchmark/index.html).
%
%   filename1 and filename2 are model generated files corresponding to
%   Case delta=-0.025m and delta=-0.10m respectively.
%    
%   Input files 'filename1' and 'filename2' need to be named as follows:
%   XXXXXX_SL_05_025.dat and XXXXXX_SL_05_100.dat, where XXXXXX is
%   the name of the numerical model that is used,
%   eg. FUNWAVE_SL_05_025.dat and FUNWAVE_SL_05_100.dat.
% 
%   The input files, 'filename1' and 'filename2' must have the following
%   configuration:
%
%   1- Files 'filename1' and 'filename2' are matrix ASCII files of size
%      801x5(row x column) (no headings)
%   2- Column 1 is time given in second, ranging form 0 to 4 sec
%      with increment of 0.005 sec.
%   3- Columns 2 and 3 are gages model results in meter
%   4- Columns 4 and 5 are runup gages results in meter
%   
%   +-----------+----------+----------+--------------+--------------+
%   | Time(sec) | Gage1(m) | Gage2(m) | RunupGage2(m)| RunupGage3(m)|
%   +-----------+----------+----------+--------------+--------------+
%          0     -0.0003456          0    0.0001761     -0.0004345
%     0.0050     -0.0003346          0    0.0001694     -0.0004768
%     0.0100     -0.0002543  0.0001467    0.0002894     -0.0004002
%          .              .          .            .              .
%          .              .          .            .              .
%          .              .          .            .              .
%     0.1850      0.0003864  0.0010835    0.0008002      0.0004784
%     0.1900      0.0003436  0.0011648    0.0006023      0.0004894
%     0.1950      0.0003231  0.0011764    0.0008367      0.0005090
%     0.2000      0.0004820  0.0013985    0.0008341      0.0005832
%          .              .          .            .              .
%          .              .          .            .              .
%          .              .          .            .              .
%     3.9800      0.0001528  0.0081391   -0.0199115      0.0007782
%     3.9850     -0.0003549  0.0080003   -0.0200863      0.0010113
%     3.9900     -0.0005610  0.0077974   -0.0201327      0.0011870
%     3.9950     -0.0007056  0.0075332   -0.0199876      0.0016674
%     4.0000     -0.0010278  0.0073547   -0.0200904      0.0017872
%   +-----------+----------+----------+--------------+--------------+
%   
%   NOTE:
%   This script is self-containing. It loads the lab. data automatically to
%   facilitate user's comparison, peer review and determine model 
%   performance.
%   The Experimental data are saved on files SL_05_025.mat and 
%   SL_05_100.mat for case delta=-0.025m and delta=-0.10m respectively.
%   Be sure that the lab data files SL_05_025.mat and SL_05_100.mat reside
%   in the same directory or subdirectory as the Matlab script
%   (LabBM_SL_05.m).
%   The user's input files 'filename1' and 'filename2' must be present
%   in the same directory or subdirectory as well.
%
%   This script uses the normalized root mean square deviation (NRMSD)
%   or root mean square error to measure the numerical model precision.
%   NRMSD measures the differences between values predicted by the
%   numerical model and the values actually observed in the experiment
%   or in the field. The NRMSD is plotted in time to visualize model
%   performance in a particular moment. As it is known tsunami models
%   usually predict fairly well the leading waves but perform poorly in
%   predicting subsequent waves. In this way users can quantify model
%   performance for the first two or three waves and so forth. 
% 
%   Examples:
%   > LabBM_SL_05
%     In this example the Matlab script just plots laboratory results.
%   > LabBM_SL_05('FUNWAVE_SL_05_025.dat','FUNWAVE_SL_05_100.dat')
%     In this example the Matlab script plots both cases, laboratory results
%     and user's model results.
%   > LabBM_SL_05('FUNWAVE_SL_05_025.dat',[])
%     In this example the Matlab script just plots laboratory results and
%     user's model result for case delta=-0.025m.
%   > LabBM_SL_05([],'FUNWAVE_SL_05_100.dat')
%     In this example the Matlab scrip plots just laboratory results and
%     user's model result for case delta=-0.10m.
% -------------------------------------------------------------------------
help LabBM_SL_05
a1=ones(801,5)*nan;
a2=ones(801,5)*nan;
len1=801; len2=801;
if nargin < 1
   filename1=['       '];
   filename2=['       '];
else
   if isempty(filename1),
      filename1=['       '];   
   else
      load(filename1);
      len=strfind(filename1, '.');
      filename1=filename1(1:len-1);      
      eval(['a=' filename1 ';']);
      eval(['clear ' filename1 ';']);
      len1=length(a);
      if len1>801,
         len1=801;
         a1=a(1:len1,:);
      else
         a1(1:len1,:)=a;
      end
   end
   if isempty(filename2),
      filename2=['       '];
   else 
      load(filename2);
      len=strfind(filename2, '.');
      filename2=filename2(1:len-1);      
      eval(['a=' filename2 ';']);
      eval(['clear ' filename2 ';']);
      len2=length(a);
      if len2>801,
         len2=801;
         a2=a(1:len2,:);
      else
         a2(1:len2,:)=a;
      end
   end
end
%
% read lab data for CASE delta=-0.025m
load SL_05_025.mat
% read lab data for CASE delta=-0.100m
load SL_05_100.mat
% BENCHMARK NAME
str='Tsunami Generation and Runup due to Three-dimensional Landslide';
% BENCHMARK CASE
str1='CASE     \Delta = -0.025m';
str2='CASE     \Delta = -0.10m';
% COLOR LAB. RESULT
cc=[0.4 0.6 0.8];
N=801;
N1=len1; N2=len2;
%
g1_025=g1_025(1:N,:);
g2_025=g2_025(1:N,:);
rg2_025=rg2_025(1:N,:);
rg3_025=rg3_025(1:N,:);
%
g1_100=g1_100(1:N,:);
g2_100=g2_100(1:N,:);
rg2_100=rg2_100(1:N,:);
rg3_100=rg3_100(1:N,:);
%
% -------------------------------------------------------------------------
% CASE DELTA=-0.025m
% -------------------------------------------------------------------------
fig2=figure;
set(fig2,'name',str,...
         'position',[100 150 1400 900]);
annotation(fig2,'textbox',...
    'String',[str '  ' str1],...
    'FontWeight','bold',...
    'FontSize',16,...
    'FitHeightToText','off',...
    'LineStyle','none',...
    'Position',[0.29 0.94 0.46 0.05]);
% -------------------------------------------------------------------------
% plot gage 1 lab result ,model result,  NRMSD delta=-0.025m
% -------------------------------------------------------------------------
subplot(2,2,1)
ax=[0 4 -0.15 0.05];
Norm=max(g1_025(:,2))-min(g1_025(:,2));
% GET RMS error
err = sqrt(sum((g1_025(1:N1,2)-a1(1:N1,2)).^2) / N1 )/Norm*100.0;
% Error
% -----
err1=[];
for ii=1:N1, 
    err1(ii,1)=sqrt(sum((g1_025(1:ii,2)-a1(1:ii,2)).^2) / ii )/Norm*100.0;
end
%
if ~isnan(err),
   % Plot gage 1, lab, model and NRMSD
   [AX,H1,H2] = plotyy([g1_025(:,1) a1(:,1)],[g1_025(:,2) a1(:,2)],g1_025(1:N1,1),err1,'plot');
   %
   set(get(AX(1),'Ylabel'),'String','\eta (m)','fontsize',14) 
   set(get(AX(2),'Ylabel'),'String','NRMSD%','fontsize',14,'color',[1 0 0])
   set(H1(1),'LineStyle','-','color',cc,'linewidth',4)
   set(H1(2),'LineStyle','--','color',[0 0 0],'linewidth',2)
   set(H2,'LineStyle','-.','color',[1 0 0],'linewidth',2)
   set(AX(1),'Ylim',[ax(3) ax(4)],...
             'ytick',[ax(3):0.05:ax(4)],...
             'yticklabel',[ax(3):0.05:ax(4)],...
             'Yminortick','on',...
             'fontsize',14,'Ycolor',[0 0 0])
   set(AX(1),'xtick',[ax(1):ax(2)],...
             'xticklabel',[ax(1):ax(2)],...
             'Xminortick','on',...
             'Xgrid','on',...
             'Xlim',[ax(1) ax(2)],...
             'fontsize',14)
   set(AX(2),'xtick',[],'xticklabel',[],'fontsize',14,'Ycolor',[1 0 0])
   %    
   text(0.50*ax(2),0.65*ax(4),[filename1(1:7) ' - NRMSD=' num2str(err) '%'],'fontsize',16)
   %
   grid on
else
   % plot gage 1
   plot(g1_025(:,1),g1_025(:,2),'linewidth',4,'color',cc)
   set(gca,'ytick',[ax(3):0.05:ax(4)],...
           'yticklabel',[ax(3):0.05:ax(4)],...
           'Ylim',[ax(3) ax(4)],...
           'Yminortick','on',...
           'Ygrid','on',...
           'xtick',[ax(1):ax(2)],...
           'xticklabel',[ax(1):ax(2)],...
           'Xminortick','on',...
           'Xgrid','on',...
           'Xlim',[ax(1) ax(2)],...
           'fontsize',14)  
   ylabel('\eta (m)','fontsize',16,'rotation',90);
end
text(0.80*ax(2),0.9*ax(4),'Gage 1','fontsize',16)
legend('EXPERIMENT',filename1(1:7),'NRMSD(t)%','location','best');
xlabel('t(sec)','fontsize',16)
%--------------------------------------------------------------------------
% plot gage 2 -lab result-and NRMSD delta=-0.025m
%--------------------------------------------------------------------------
subplot(2,2,3)
ax=[0 4 -0.10 0.05];
Norm=max(g2_025(:,2))-min(g2_025(:,2));
% GET RMS error
err = sqrt(sum((g2_025(1:N1,2)-a1(1:N1,3)).^2) / N1 )/Norm*100.0;
% Error
% -----
err1=[];
for ii=1:N1, 
    err1(ii,1)=sqrt(sum((g2_025(1:ii,2)-a1(1:ii,3)).^2) / ii )/Norm*100.0;
end
%
if ~isnan(err),
   % Plot gage 2, numerical result and NRMSD
   [AX,H1,H2] = plotyy([g2_025(:,1) a1(:,1)],[g2_025(:,2) a1(:,3)],g2_025(1:N1,1),err1,'plot');
   %
   set(get(AX(1),'Ylabel'),'String','\eta (m)','fontsize',14) 
   set(get(AX(2),'Ylabel'),'String','NRMSD%','fontsize',14,'color',[1 0 0])
   set(H1(1),'LineStyle','-','color',cc,'linewidth',4)
   set(H1(2),'LineStyle','--','color',[0 0 0],'linewidth',2)
   set(H2,'LineStyle','-.','color',[1 0 0],'linewidth',2)
   set(AX(1),'Ylim',[ax(3) ax(4)],...
             'ytick',[ax(3):0.05:ax(4)],...
             'yticklabel',[ax(3):0.05:ax(4)],...
             'Yminortick','on',...
             'fontsize',14,'Ycolor',[0 0 0])
   set(AX(1),'xtick',[ax(1):ax(2)],...
             'xticklabel',[ax(1):ax(2)],...
             'Xminortick','on',...
             'Xgrid','on',...
             'Xlim',[ax(1) ax(2)],...
             'fontsize',14)
   set(AX(2),'xtick',[],'xticklabel',[],'fontsize',14,'Ycolor',[1 0 0])
   %    
   text(0.50*ax(2),0.65*ax(4),[filename1(1:7) ' - NRMSD=' num2str(err) '%'],'fontsize',16)
   %
   grid on
else
   % plot gage 2
   plot(g2_025(:,1),g2_025(:,2),'linewidth',4,'color',cc)
   set(gca,'ytick',[ax(3):0.05:ax(4)],...
           'yticklabel',[ax(3):0.05:ax(4)],...
           'Ylim',[ax(3) ax(4)],...
           'Yminortick','on',...
           'Ygrid','on',...
           'xtick',[ax(1):ax(2)],...
           'xticklabel',[ax(1):ax(2)],...
           'Xminortick','on',...
           'Xgrid','on',...
           'Xlim',[ax(1) ax(2)],...
           'fontsize',14)  
   ylabel('\eta (m)','fontsize',16,'rotation',90);
end
text(0.80*ax(2),0.9*ax(4),'Gage 2','fontsize',16)
xlabel('t(sec)','fontsize',16)
% -------------------------------------------------------------------------
% plot Runup gage 2 lab result, model results and NRMSD delta=-0.025m 
% -------------------------------------------------------------------------
subplot(2,2,2)
ax=[0 4 -0.08 0.04];
Norm=max(rg2_025(:,2))-min(rg2_025(:,2));
% GET RMS error
err = sqrt(sum((rg2_025(1:N1,2)-a1(1:N1,4)).^2) / N1 )/Norm*100.0;
% Error
% -----
err1=[];
for ii=1:N1, 
    err1(ii,1)=sqrt(sum((rg2_025(1:ii,2)-a1(1:ii,4)).^2) / ii )/Norm*100.0;
end
%
if ~isnan(err),
   % Plot Runup gage 2, numerical result and NRMSD
   [AX,H1,H2] = plotyy([rg2_025(:,1) a1(:,1)],[rg2_025(:,2) a1(:,4)],rg2_025(1:N1,1),err1,'plot');
   %
   set(get(AX(1),'Ylabel'),'String','R (m)','fontsize',14) 
   set(get(AX(2),'Ylabel'),'String','NRMSD%','fontsize',14,'color',[1 0 0])
   set(H1(1),'LineStyle','-','color',cc,'linewidth',4)
   set(H1(2),'LineStyle','--','color',[0 0 0],'linewidth',2)
   set(H2,'LineStyle','-.','color',[1 0 0],'linewidth',2)
   set(AX(1),'Ylim',[ax(3) ax(4)],...
             'ytick',[ax(3):0.04:ax(4)],...
             'yticklabel',[ax(3):0.04:ax(4)],...
             'Yminortick','on',...
             'fontsize',14,'Ycolor',[0 0 0])
   set(AX(1),'xtick',[ax(1):ax(2)],...
             'xticklabel',[ax(1):ax(2)],...
             'Xminortick','on',...
             'Xgrid','on',...
             'Xlim',[ax(1) ax(2)],...
             'fontsize',14)
   set(AX(2),'xtick',[],'xticklabel',[],'fontsize',14,'Ycolor',[1 0 0])
   %    
   text(0.50*ax(2),0.65*ax(4),[filename1(1:7) ' - NRMSD=' num2str(err) '%'],'fontsize',16)
   %
   grid on
else
   % plot Runup gage 2
   plot(rg2_025(:,1),rg2_025(:,2),'linewidth',4,'color',cc)
   set(gca,'ytick',[ax(3):0.04:ax(4)],...
           'yticklabel',[ax(3):0.04:ax(4)],...
           'Ylim',[ax(3) ax(4)],...
           'Yminortick','on',...
           'Ygrid','on',...
           'xtick',[ax(1):ax(2)],...
           'xticklabel',[ax(1):ax(2)],...
           'Xminortick','on',...
           'Xgrid','on',...
           'Xlim',[ax(1) ax(2)],...
           'fontsize',14)  
   ylabel('R (m)','fontsize',16,'rotation',90);
end
text(0.70*ax(2),0.9*ax(4),'Runup Gage 2','fontsize',16)
%legend('EXPERIMENT',filename(1:7),'NRMSD(t)%','location','best');
xlabel('t(sec)','fontsize',16)
% ------------------------------------------------------------------------
% plot Runup gage 3, lab result and NRMSD delta=-0.025m 
% ------------------------------------------------------------------------
subplot(2,2,4)
ax=[0 4 -0.08 0.04];
Norm=max(rg3_025(:,2))-min(rg3_025(:,2));
% GET RMS error
err = sqrt(sum((rg3_025(1:N1,2)-a1(1:N1,5)).^2) / N1 )/Norm*100.0;
% Error
% -----
err1=[];
for ii=1:N1, 
    err1(ii,1)=sqrt(sum((rg3_025(1:ii,2)-a1(1:ii,5)).^2) / ii )/Norm*100.0;
end
%
if ~isnan(err),
   % Plot Runup gage 3, Lab result and NRMSD
   [AX,H1,H2] = plotyy([rg3_025(:,1) a1(:,1)],[rg3_025(:,2) a1(:,5)],rg3_025(1:N1,1),err1,'plot');
   %
   set(get(AX(1),'Ylabel'),'String','R (m)','fontsize',14) 
   set(get(AX(2),'Ylabel'),'String','NRMSD%','fontsize',14,'color',[1 0 0])
   set(H1(1),'LineStyle','-','color',cc,'linewidth',4)
   set(H1(2),'LineStyle','--','color',[0 0 0],'linewidth',2)
   set(H2,'LineStyle','-.','color',[1 0 0],'linewidth',2)
   set(AX(1),'Ylim',[ax(3) ax(4)],...
             'ytick',[ax(3):0.04:ax(4)],...
             'yticklabel',[ax(3):0.04:ax(4)],...
             'Yminortick','on',...
             'fontsize',14,'Ycolor',[0 0 0])
   set(AX(1),'xtick',[ax(1):ax(2)],...
             'xticklabel',[ax(1):ax(2)],...
             'Xminortick','on',...
             'Xgrid','on',...
             'Xlim',[ax(1) ax(2)],...
             'fontsize',14)
   set(AX(2),'xtick',[],'xticklabel',[],'fontsize',14,'Ycolor',[1 0 0])
   %    
   text(0.50*ax(2),0.65*ax(4),[filename2(1:7) ' - NRMSD=' num2str(err) '%'],'fontsize',16)
   %
   grid on
else
   % plot Runup gage 3
   plot(rg3_025(:,1),rg3_025(:,2),'linewidth',4,'color',cc)
   set(gca,'ytick',[ax(3):0.04:ax(4)],...
           'yticklabel',[ax(3):0.04:ax(4)],...
           'Ylim',[ax(3) ax(4)],...
           'Yminortick','on',...
           'Ygrid','on',...
           'xtick',[ax(1):ax(2)],...
           'xticklabel',[ax(1):ax(2)],...
           'Xminortick','on',...
           'Xgrid','on',...
           'Xlim',[ax(1) ax(2)],...
           'fontsize',14)  
   ylabel('R (m)','fontsize',16,'rotation',90);
end
text(0.70*ax(2),0.9*ax(4),'Runup Gage 3','fontsize',16)
xlabel('t(sec)','fontsize',16)
%
% -------------------------------------------------------------------------
% CASE DELTA=-0.100m
% -------------------------------------------------------------------------
fig1=figure;
set(fig1,'name',str,...
         'position',[150 100 1400 900]);
annotation(fig1,'textbox',...
    'String',[str '  ' str2],...
    'FontWeight','bold',...
    'FontSize',16,...
    'FitHeightToText','off',...
    'LineStyle','none',...
    'Position',[0.29 0.94 0.46 0.05]);
% -------------------------------------------------------------------------
% plot gage 1 -lab result- delta=-0.10m
% -------------------------------------------------------------------------
subplot(2,2,1)
ax=[0 4 -0.10 0.05];
Norm=max(g1_100(:,2))-min(g1_100(:,2));
% GET RMS error
err = sqrt(sum((g1_100(1:N2,2)-a2(1:N2,2)).^2) / N2 )/Norm*100.0;
% Error
% -----
err1=[];
for ii=1:N2, 
    err1(ii,1)=sqrt(sum((g1_100(1:ii,2)-a2(1:ii,2)).^2) / ii )/Norm*100.0;
end
%
if ~isnan(err),
   % Plot gage 1, lab, model and NRMSD
   [AX,H1,H2] = plotyy([g1_100(:,1) a2(:,1)],[g1_100(:,2) a2(:,2)],g1_100(1:N2,1),err1,'plot');
   %
   set(get(AX(1),'Ylabel'),'String','\eta (m)','fontsize',14) 
   set(get(AX(2),'Ylabel'),'String','NRMSD%','fontsize',14,'color',[1 0 0])
   set(H1(1),'LineStyle','-','color',cc,'linewidth',4)
   set(H1(2),'LineStyle','--','color',[0 0 0],'linewidth',2)
   set(H2,'LineStyle','-.','color',[1 0 0],'linewidth',2)
   set(AX(1),'Ylim',[ax(3) ax(4)],...
             'ytick',[ax(3):0.05:ax(4)],...
             'yticklabel',[ax(3):0.05:ax(4)],...
             'Yminortick','on',...
             'fontsize',14,'Ycolor',[0 0 0])
   set(AX(1),'xtick',[ax(1):ax(2)],...
             'xticklabel',[ax(1):ax(2)],...
             'Xminortick','on',...
             'Xgrid','on',...
             'Xlim',[ax(1) ax(2)],...
             'fontsize',14)
   set(AX(2),'xtick',[],'xticklabel',[],'fontsize',14,'Ycolor',[1 0 0])
   %    
   text(0.50*ax(2),0.65*ax(4),[filename2(1:7) ' - NRMSD=' num2str(err) '%'],'fontsize',16)
   %
   grid on
else
   % plot gage 1
   plot(g1_100(:,1),g1_100(:,2),'linewidth',4,'color',cc)
   set(gca,'ytick',[ax(3):0.05:ax(4)],...
           'yticklabel',[ax(3):0.05:ax(4)],...
           'Ylim',[ax(3) ax(4)],...
           'Yminortick','on',...
           'Ygrid','on',...
           'xtick',[ax(1):ax(2)],...
           'xticklabel',[ax(1):ax(2)],...
           'Xminortick','on',...
           'Xgrid','on',...
           'Xlim',[ax(1) ax(2)],...
           'fontsize',14)  
   ylabel('\eta (m)','fontsize',16,'rotation',90);
end
text(0.80*ax(2),0.9*ax(4),'Gage 1','fontsize',16)
legend('EXPERIMENT',filename2(1:7),'NRMSD(t)%','location','best');
xlabel('t(sec)','fontsize',16)
% -------------------------------------------------------------------------
% plot gage 2 lab result, model and NRMSD delta=-0.10m
% -------------------------------------------------------------------------
subplot(2,2,3)
ax=[0 4 -0.05 0.05];
Norm=max(g2_100(:,2))-min(g2_100(:,2));
% GET RMS error
err = sqrt(sum((g2_100(1:N2,2)-a2(1:N2,3)).^2) / N2 )/Norm*100.0;
% Error
% -----
err1=[];
for ii=1:N2, 
    err1(ii,1)=sqrt(sum((g2_100(1:ii,2)-a2(1:ii,3)).^2) / ii )/Norm*100.0;
end
%
if ~isnan(err),
   % Plot gage 2, numerical result and NRMSD
   [AX,H1,H2] = plotyy([g2_100(:,1) a2(:,1)],[g2_100(:,2) a2(:,3)],g2_100(1:N2,1),err1,'plot');
   %
   set(get(AX(1),'Ylabel'),'String','\eta (m)','fontsize',14) 
   set(get(AX(2),'Ylabel'),'String','NRMSD%','fontsize',14,'color',[1 0 0])
   set(H1(1),'LineStyle','-','color',cc,'linewidth',4)
   set(H1(2),'LineStyle','--','color',[0 0 0],'linewidth',2)
   set(H2,'LineStyle','-.','color',[1 0 0],'linewidth',2)
   set(AX(1),'Ylim',[ax(3) ax(4)],...
             'ytick',[ax(3):0.05:ax(4)],...
             'yticklabel',[ax(3):0.05:ax(4)],...
             'Yminortick','on',...
             'fontsize',14,'Ycolor',[0 0 0])
   set(AX(1),'xtick',[ax(1):ax(2)],...
             'xticklabel',[ax(1):ax(2)],...
             'Xminortick','on',...
             'Xgrid','on',...
             'Xlim',[ax(1) ax(2)],...
             'fontsize',14)
   set(AX(2),'xtick',[],'xticklabel',[],'fontsize',14,'Ycolor',[1 0 0])
   %    
   text(0.50*ax(2),0.65*ax(4),[filename2(1:7) ' - NRMSD=' num2str(err) '%'],'fontsize',16)
   %
   grid on
else
   % plot gage 2
   plot(g2_100(:,1),g2_100(:,2),'linewidth',4,'color',cc)
   set(gca,'ytick',[ax(3):0.05:ax(4)],...
           'yticklabel',[ax(3):0.05:ax(4)],...
           'Ylim',[ax(3) ax(4)],...
           'Yminortick','on',...
           'Ygrid','on',...
           'xtick',[ax(1):ax(2)],...
           'xticklabel',[ax(1):ax(2)],...
           'Xminortick','on',...
           'Xgrid','on',...
           'Xlim',[ax(1) ax(2)],...
           'fontsize',14)  
   ylabel('\eta (m)','fontsize',16,'rotation',90);
end
text(0.80*ax(2),0.9*ax(4),'Gage 2','fontsize',16)
xlabel('t(sec)','fontsize',16)
% -------------------------------------------------------------------------
% plot Runup gage 2 -lab result- delta=-0.10m
% -------------------------------------------------------------------------
subplot(2,2,2)
ax=[0 4 -0.05 0.05];
Norm=max(rg2_100(:,2))-min(rg2_100(:,2));
% GET RMS error
err = sqrt(sum((rg2_100(1:N2,2)-a2(1:N2,4)).^2) / N2 )/Norm*100.0;
% Error
% -----
err1=[];
for ii=1:N2, 
    err1(ii,1)=sqrt(sum((rg2_100(1:ii,2)-a2(1:ii,4)).^2) / ii )/Norm*100.0;
end
%
if ~isnan(err),
   % Plot Runup gage 2, numerical result and NRMSD
   [AX,H1,H2] = plotyy([rg2_100(:,1) a2(:,1)],[rg2_100(:,2) a2(:,4)],rg2_100(1:N2,1),err1,'plot');
   %
   set(get(AX(1),'Ylabel'),'String','R (m)','fontsize',14) 
   set(get(AX(2),'Ylabel'),'String','NRMSD%','fontsize',14,'color',[1 0 0])
   set(H1(1),'LineStyle','-','color',cc,'linewidth',4)
   set(H1(2),'LineStyle','--','color',[0 0 0],'linewidth',2)
   set(H2,'LineStyle','-.','color',[1 0 0],'linewidth',2)
   set(AX(1),'Ylim',[ax(3) ax(4)],...
             'ytick',[ax(3)-0.03:0.04:ax(4)+0.03],...
             'yticklabel',[ax(3)-0.03:0.04:ax(4)+0.03],...
             'Yminortick','on',...
             'fontsize',14,'Ycolor',[0 0 0])
   set(AX(1),'xtick',[ax(1):ax(2)],...
             'xticklabel',[ax(1):ax(2)],...
             'Xminortick','on',...
             'Xgrid','on',...
             'Xlim',[ax(1) ax(2)],...
             'fontsize',14)
   set(AX(2),'xtick',[],'xticklabel',[],'fontsize',14,'Ycolor',[1 0 0])
   %    
   text(0.50*ax(2),0.65*ax(4),[filename2(1:7) ' - NRMSD=' num2str(err) '%'],'fontsize',16)
   %
   grid on
else
   % plot Runup gage 2
   plot(rg2_100(:,1),rg2_100(:,2),'linewidth',4,'color',cc)
   set(gca,'ytick',[ax(3)-0.03:0.04:ax(4)+0.03],...
           'yticklabel',[ax(3)-0.03:0.04:ax(4)+0.03],...
           'Ylim',[ax(3) ax(4)],...
           'Yminortick','on',...
           'Ygrid','on',...
           'xtick',[ax(1):ax(2)],...
           'xticklabel',[ax(1):ax(2)],...
           'Xminortick','on',...
           'Xgrid','on',...
           'Xlim',[ax(1) ax(2)],...
           'fontsize',14)  
   ylabel('R (m)','fontsize',16,'rotation',90);
end
text(0.70*ax(2),0.9*ax(4),'Runup Gage 2','fontsize',16)
%legend('EXPERIMENT',filename(1:7),'NRMSD(t)%','location','best');
xlabel('t(sec)','fontsize',16)
% -------------------------------------------------------------------------
% plot Runup gage 3 -lab result- delta=-0.10m
% -------------------------------------------------------------------------
subplot(2,2,4)
ax=[0 4 -0.05 0.05];
Norm=max(rg3_100(:,2))-min(rg3_100(:,2));
% GET RMS error
err = sqrt(sum((rg3_100(1:N2,2)-a2(1:N2,5)).^2) / N2 )/Norm*100.0;
% Error
% -----
err1=[];
for ii=1:N2, 
    err1(ii,1)=sqrt(sum((rg3_100(1:ii,2)-a2(1:ii,5)).^2) / ii )/Norm*100.0;
end
%
if ~isnan(err),
   % Plot Runup gage 3, Lab result and NRMSD
   [AX,H1,H2] = plotyy([rg3_100(:,1) a2(:,1)],[rg3_100(:,2) a2(:,5)],rg3_100(1:N2,1),err1,'plot');
   %
   set(get(AX(1),'Ylabel'),'String','R (m)','fontsize',14) 
   set(get(AX(2),'Ylabel'),'String','NRMSD%','fontsize',14,'color',[1 0 0])
   set(H1(1),'LineStyle','-','color',cc,'linewidth',4)
   set(H1(2),'LineStyle','--','color',[0 0 0],'linewidth',2)
   set(H2,'LineStyle','-.','color',[1 0 0],'linewidth',2)
   set(AX(1),'Ylim',[ax(3) ax(4)],...
             'ytick',[ax(3)-0.03:0.04:ax(4)+0.03],...
             'yticklabel',[ax(3)-0.03:0.04:ax(4)+0.03],...
             'Yminortick','on',...
             'fontsize',14,'Ycolor',[0 0 0])
   set(AX(1),'xtick',[ax(1):ax(2)],...
             'xticklabel',[ax(1):ax(2)],...
             'Xminortick','on',...
             'Xgrid','on',...
             'Xlim',[ax(1) ax(2)],...
             'fontsize',14)
   set(AX(2),'xtick',[],'xticklabel',[],'fontsize',14,'Ycolor',[1 0 0])
   %    
   text(0.50*ax(2),0.65*ax(4),[filename2(1:7) ' - NRMSD=' num2str(err) '%'],'fontsize',16)
   %
   grid on
else
   % plot Runup gage 3
   plot(rg3_100(:,1),rg3_100(:,2),'linewidth',4,'color',cc)
   set(gca,'ytick',[ax(3)-0.03:0.04:ax(4)+0.03],...
           'yticklabel',[ax(3)-0.03:0.04:ax(4)+0.03],...
           'Ylim',[ax(3) ax(4)],...
           'Yminortick','on',...
           'Ygrid','on',...
           'xtick',[ax(1):ax(2)],...
           'xticklabel',[ax(1):ax(2)],...
           'Xminortick','on',...
           'Xgrid','on',...
           'Xlim',[ax(1) ax(2)],...
           'fontsize',14)  
   ylabel('R (m)','fontsize',16,'rotation',90);
end
text(0.70*ax(2),0.9*ax(4),'Runup Gage 3','fontsize',16)
xlabel('t(sec)','fontsize',16)
 return

