Main Content

matlab.io.hdfeos.gd.writeField

Namespace: matlab.io.hdfeos.gd

Write data to grid field

Syntax

writeField(gridID,fieldname,data)
writeField(gridID,fieldname,start,data)
writeField(gridID,fieldname,start,stride,data)

Description

writeField(gridID,fieldname,data) writes all the data to a grid field. The field is identified by fieldname and the grid is identified by gridID.

writeField(gridID,fieldname,start,data) writes a contiguous hyperslab to the grid field. start specifies the zero-based starting index.

writeField(gridID,fieldname,start,stride,data) writes a strided hyperslab of data to a grid data field. stride specifies the inter-element spacing along each dimension. The number of elements to write along each dimension is inferred from the size of data.

This function corresponds to the GDwritefield function in the HDF-EOS library C API, but because MATLAB® uses FORTRAN-style ordering, the start and stride parameters are reversed with respect to the C library API.

Examples

Write all the data to a grid field.

import matlab.io.hdfeos.*
srcFile = fullfile(matlabroot,"toolbox","matlab","matlab_sci","hdf4","grid.hdf");
copyfile(srcFile,"myfile.hdf")
fileattrib("myfile.hdf","+w")
gfid = gd.open("myfile.hdf","rdwr");
gridID = gd.attach(gfid,"PolarGrid");
data = zeros(100,100,"uint16");
gd.writeField(gridID,"ice_temp",data)
gd.detach(gridID)
gd.close(gfid)