Function to write a .asc or .txt file with a regular grid form X Y Z matrixes
Inputs
filename file name
X Y coordinate matrixes
noval remplace nan value in Z matrix
n data precision
Example
[X,Y]=meshgrid(0:.01:1);
Z=sin(X)+cos(Y);
xyz2asc('example.asc',X,Y,Z,-9999,2);