function f = viewfig(obs,pred,flag)
%CREATEFIGURE1(RES_VERF1,YMATRIX1)
%  RES_VERF1:  vector of x data
%  YMATRIX1:  matrix of y data

%  Auto-generated by MATLAB on 10-Jun-2008 18:14:54
%load mytest
YMatrix1 = [obs pred];
x=1:length(obs);
n = length(obs);
% res_verf1=res_verf(:,1);
% YMatrix1 = res_verf(:,2:3);
% Create figure
f = figure('PaperSize',[20.98 29.68],'Position',[50 300 600 500],'visible',flag);
%f = figure('PaperSize',[20.98 29.68]);
% Create axes
axes1 = axes('Parent',f,'Position',[0.08043 0.6038 0.875013 0.3554]);
box('on');
hold('all');

% Create multiple lines using matrix input to plot
plot1 = plot(x,YMatrix1,'Parent',axes1);
set(plot1(1),'DisplayName','observed');
set(plot1(2),'DisplayName','predicted');
set(plot1(1),'color',[0.5 0.5 0.5],'LineWidth',2)
set(plot1(2),'color','b')

xlim(axes1,[0 n]) 
ylim(axes1,[0 max(max(YMatrix1))]) 
% Create xlabel
xlabel('Time (hr)');

% Create ylabel
ylabel('Median of discharge');
%legend(axes1,'Observed','Predicted')

%% Zoomed axis
x=4200:4500;

% Create axes
axes2 = axes('Parent',f,'Position',[0.08043 0.09201 0.4089 0.4118]);
% Uncomment the following line to preserve the X-limits of the axes
% xlim([4200 4500]);
box('on');
hold('all');

% Create multiple lines using matrix input to plot
plot2 = plot(x,YMatrix1(x,:),'Parent',axes2);
set(plot2(1),'color',[0.5 0.5 0.5],'LineWidth',2)
set(plot2(2),'color','b')
ylim(axes2,[0 max(max(YMatrix1(x,:)))]) 
x=4700:5000;
% Create axes
axes3 = axes('Parent',f,'Position',[0.5703 0.09201 0.3835 0.4133]);
% Uncomment the following line to preserve the X-limits of the axes
% xlim([4700 5000]);
box('on');
hold('all');

% Create multiple lines using matrix input to plot
plot3 = plot(x,YMatrix1(x,:),'Parent',axes3);
set(plot3(1),'color',[0.5 0.5 0.5],'LineWidth',2)
set(plot3(2),'color','b')
ylim(axes3,[0 max(max(YMatrix1(x,:)))]) 
% Create legend
legend(axes1,'show','Location','Best');
%print -dtiff -r900 picture1
% [pathstr, name, ext, versn] = fileparts(figName) ;
% switch  ext
%     case '.fig'
%         saveas(f,figName) 
%     case '.tiff'
%       print(f,'-dtiff', '-r900', figName)  
%     case '.emf'
%         print(f,'-dmeta', '-r2400', figName)
%     case '.eps'
%         print(f,'-depsc', '-r2400', figName)  
%     otherwise
%         error('does not know the figure format')
% end
%delete(f)
