%
% Example 6.3:  Sampling and Averaging Intervals
%
% Bob Newell, March 1996
%--------------------------------------------------------------
load flow.dat
%
fontsz = 20;
figure
plot( flow(1:564,1), flow(1:564,2) )
set( gca, 'fontsize', fontsz );
xlabel( 'Time in hours' );
ylabel( 'Flowrate' );
%
fontsz = 24;
figure
offset = 0;
for n = [ 96 48 24 6 1 ],
  plot( flow(1:n:564,1), flow(1:n:564,2) + offset )
  set( gca, 'fontsize', fontsz );
  xlabel( 'Time in hours' );
  ylabel( 'Offset Flowrates' );
  hold on
  offset = offset + 5;
  if n == 96, offset = offset + 2; end;
end;
hold off
%
figure
offset = 0;
averages = zeros( length(flow),1 );
for n = [ 288 180 108 12 1 ],
  j = n;
  for i = 1:564,
    if j < n,
	  j = j + 1;
	else,
	  av = mean( flow(i:i+n,2) );
	  j = 1;
	end;
    averages(i) = av;
  end;
  plot( flow(1:564,1), averages(1:564) + offset )
  set( gca, 'fontsize', fontsz );
  xlabel( 'Time in hours' );
  ylabel( 'Offset Flowrates' );
  hold on
  offset = offset + 5;
%  if n == 96, offset = offset + 2; end;
end;
hold off
%
print -f1 -deps2 ex6-4a.eps
print -f2 -deps2 ex6-4b.eps
print -f3 -deps2 ex6-4c.eps
%
