matlab.io.hdf4.sd.setFillMode
Package: matlab.io.hdf4.sd
Set current fill mode of file
Syntax
prevmode = setFillMode(sdID,fillmode)
Description
prevmode = setFillMode(sdID,fillmode)
returns
the previous fill mode of a file and resets it to fillmode
.
This setting applies to all data sets contained in the file identified
by sdID
.
Possible values of fillmode
are 'fill'
,
and 'nofill'
. 'fill'
is the
default mode and indicates that fill values will be written when the
data set is created. 'nofill'
indicates that the
fill values will not be written.
When a fixed-size data set is created, the first call to sd.writeData
will fill the entire data set with the default or user-defined fill
value if fillmode
is 'fill'
.
In data sets with an unlimited dimension, if a new write operation
takes place along the unlimited dimension beyond the last location
of the previous write operation, the array locations between these
written areas will be initialized to the user-defined fill value,
or the default fill value if a user-defined fill value has not been
specified.
If it is certain that all data set values will be written before
any read operation takes place, there is no need to write the fill
values. Calling sd.setFillMode
with 'nofill'
can
improve performance in this case.
This function corresponds to the SDsetfillmode
function
in the HDF library C API.
Examples
Write two partial records. Write the first in 'nofill'
mode,
and the second with 'fill'
mode.
import matlab.io.hdf4.* sdID = sd.start('myfile.hdf','create'); sd.setFillMode(sdID,'nofill'); sdsID = sd.create(sdID,'temperature','double',[10 10 0]); sd.writeData(sdsID,[0 0 0], rand(5,5)); sd.setFillMode(sdID,'fill'); sd.setFillValue(sdsID,-999); sd.writeData(sdsID,[0 0 1], rand(5,5)); sd.endAccess(sdsID); sd.close(sdID);