%  PlotRectVsElt.m
%
%  Jiangguo (James) Liu
%  ColoState, Nov. 2006

clear all;
close all;

NumRectVsTrigs = zeros(1,20);
MinNumTrigs = 20;
MaxNumTrigs = 0;

fp = fopen('RectVsElts.dat','r');
NumRects = fscanf(fp,'%d',1);
for i=1:NumRects
   m = fscanf(fp,'%d',1);
   NumTrigsThisRect = fscanf(fp,'%d',1);
   if NumTrigsThisRect>MaxNumTrigs
      MaxNumTrigs = NumTrigsThisRect;
   end
   if NumTrigsThisRect<MinNumTrigs 
      MinNumTrigs = NumTrigsThisRect;
   end
   NumRectVsTrigs(NumTrigsThisRect) = NumRectVsTrigs(NumTrigsThisRect)+1;
   trash = zeros(1,NumTrigsThisRect);
   trash = fscanf(fp, '%d', NumTrigsThisRect);
end
fclose(fp);

figure(1);
X = MinNumTrigs:MaxNumTrigs;
Y = NumRectVsTrigs(MinNumTrigs:MaxNumTrigs);
bar(X,Y);
axis tight;
print -f1 -depsc2 RectVsTrig.eps;

disp('Press any key to close all windows...');
pause;
close all;

return;
