function result = plotAll_v2(cellArray)
%plotAll_v2   given an nx2 cellArray of vectors, plot each row 
%
% consumes: cellArray, a cell array 
%                      should be n rows by 2 columns
%
%                      each row should contain two numeric row vectors of
%                      equal length, representing x and y
%                      coordinates
%
% produces: result: true if successful, false if not successful
%
% Example: Plot the capital letter A in the box with 0,0 at lower
%          left and 4,8 at upper right.
%
%
%     >> myPlot = cell(2,1);
%     >> myPlot{1} = [0 0; 2 8; 4 0];
%     >> myPlot{2} = [1 3; 4 4];
%     >> plotAll_v2(myPlot);
%     >> print('-djpeg','myPlot.jpg');
%
% P. Conrad   for CISC106, 10/16/2007

  result = true;

  [rows, cols] = size(cellArray);

  % make sure there is exactly 1 column

  if (cols ~= 1)
    result = false;
    return;
  end

  % make sure that every row contains a matrix with exactly 2 columns

  for i=1:rows
    thisMatrix = cellArray{i,1};
    [thisMRows, thisMcols] = size(thisMatrix);
    
    if (thisMcols ~= 2)
      result = false;
      return;
    end      
  end
  
  % clear the current graphics figure
  % and make aspect ratio equal on x and y axis
  
  close gcf;
  
  % plot each line

  for i=1:rows
    thisMatrix = cellArray{i,1};
    xValues = thisMatrix(:,1);
    yValues = thisMatrix(:,2);
    plot(xValues,yValues);
    if (i<rows)
      hold on;
    end
  end

  
  axis equal tight;  
      
end % plotAll_v2.m
