Surfer Grid import/export

Import and export GS ASCII (GRD files) from and to Golden Software Applications like Surfer and Grap
5,4K Descargas
Actualizado 13 abr 2009

Sin licencia

Surfer Grid, import/export.

Matlab <-> Golden Software Surfer and Grapher

The pack contains two simple routines: grd_write.m and grd_read.m. They communicate Matlab with Golden Software Surfer by the GRD file format (ASCII version).

grd_write(matrix,xmin,xmax,ymin,ymax,namefile)
Input:
matrix = matrix to export
xmin,xmax,ymin,ymax = grid limits
namefile = name of the file to be written (include ".grd" extension)
Output:
grd file in current directory

[matrix xmin xmax ymin ymax]=grd_read(name of file)
Input:
nomarch = name of the file to be read, including ".grd" extension
Output:
matrix = matrix of the read data
xmin xmax ymin ymax = grid limits

* NOTE: Previous version of grd_read worked only with files saved in Surfer (or Grapher), but now is SOLVED. It runs faster also.

Example of use:

Creation of a matrix in Matlab:

x=linspace(-4,4,100);
y=linspace(-5,5,100);
[X,Y]=meshgrid(x,y);
Z=cos(sqrt(X.^2+Y.^2));

Export to surfer:

grd_write(Z,min(x),max(x),min(y),max(y),'example.grd')

Open in surfer and save as:

Open example.grd in Surfer (as a grid: file-> open). Then save it, for example with the name example_saved_by_surfer.grd. Remember to chose “GS ASCII (*.grd)”.

Load the saved file in Matlab

[matrix xmin xmax ymin ymax]=grd_read('example_saved_by_surfer.grd');

---Coded by Alberto Avila Armella, updated and improved by Jose Maria Garcia-Valdecasas

Citar como

Alberto Avila Armella (2025). Surfer Grid import/export (https://es.mathworks.com/matlabcentral/fileexchange/20880-surfer-grid-import-export), MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2007a
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux
Agradecimientos

Inspiración para: xyz2grd

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Versión Publicado Notas de la versión
1.1.0.0

Previous version of grd_read worked only with files saved in Surfer (or Grapher), but now is SOLVED (by Jose Maria Garcia-Valdecasas). It runs faster also.

1.0.0.0