function [dgr] = dattogr(dmat, nx, ny)
% [dgr] = dattogr(dmat, nr, nc);
% function to convert a data matrix, dmat, consisting 
% of 3 cols (x,y,z), arranged in order: x =1, all y; 
% x=2, all y, etc to a data grid, dmat, with nx columns 
% and ny rows of z values.
% Written by Gerry Middleton, October 1996
k = 1; 
for i = 1:nx
   for j = 1:ny
      dgr(j,i) = dmat(k,3);
      k = k+1;
   end
end

