matlab.io.hdfeos.sw.writeField
Namespace: matlab.io.hdfeos.sw
Write data to swath field
Syntax
writeField(swathID,fieldname,data)
writeField(swathID,fieldname,start,data)
writeField(swathID,fieldname,start,stride,data)
Description
writeField(swathID,fieldname,data)
writes
an entire swath data field.
writeField(swathID,fieldname,start,data)
writes
a contiguous hyperslab to a swath field. start
specifies
the index of the first element to write. The number of elements along
each dimension is inferred from either the size of data
or
from the swath field itself.
writeField(swathID,fieldname,start,stride,data)
writes
a strided hyperslab to a swath field. stride
specifies
the inter-element spacing along each dimension.
This function corresponds to the SWwritefield
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 data to a geolocation field 'Longitude'
.
lon = [-50:49]; data = repmat(lon(:),1,100); data = single(data); import matlab.io.hdfeos.* srcFile = fullfile(matlabroot,"toolbox","matlab","matlab_sci","hdf4","swath.hdf"); copyfile(srcFile,"myfile.hdf") fileattrib("myfile.hdf","+w") swfid = sw.open("myfile.hdf","rdwr"); swathID = sw.attach(swfid,"Example Swath"); sw.writeField(swathID,"Longitude",data) sw.detach(swathID) sw.close(swfid)