function data=genspace(m)

% GENSPACE    Convert matrix to dataset.
%
%             Example: m=ceil(10*rand(8)), data=genspace(m);
%
%             Christian C. Beardah 1996

count=1;

[i,j,s]=find(m);
datasize=sum(s);
data=zeros(datasize,2);

for k=1:length(i),
  n=s(k);
  data([count:(count+n-1)],1:2)=ones(n,1)*[i(k) j(k)];
  count=count+n;
end;