function mattogrid(x,y,u,name);
%function mattogrid(x,y,u,name);
%               puts data in format for input into gridder
%               If there is only one z variable, use gridder.exe;
%               otherwise use gridmul
%               for Gay Head data, use \ghsurf\grid
n=length(x);
[nu,mu]=size(u);
if nu~=n
    u=u';
    mu=nu;
end
out(:,1)=x;
out(:,2)=y;
out(:,3:2+mu)=u;
out=denan(out);
save dummy.dat out /ascii
if nargin==3
     name=input(' name of output file (no ext.) ');
end
disp(['will overwrite ',name,'.dat']);
pause
eval(['!copy dummy.dat ',name,'.dat']);
!del dummy.dat
disp(' now run gridder.exe (in e:\surf).  You may have to get out of matlab ');
disp('   to run it, due to memory problems.  The output of gridder can be ');
disp('   converted back into matlab format by running gridtomat.bat ');
