Main Content

matlab.io.hdf4.sd.readData

Package: matlab.io.hdf4.sd

Read subsample of data

Syntax

data = readData(sdsID)
data = readData(sdsID,start,count)
data = readData(sdsID,start,count,stride)

Description

data = readData(sdsID) reads all of the data for the data set identified by sdsID.

data = readData(sdsID,start,count) reads a contiguous hyperslab of data from the data set identified by sdsID. The start input specifies the starting position from where the hyperslab is read. count specifies the number of values to read along each data set dimension.

data = readData(sdsID,start,count,stride) reads a strided hyperslab of data from the data set identified by sdsID.

start, count, and stride use zero-based indexing.

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

Examples

Read an entire data set.

import matlab.io.hdf4.*
sdID = sd.start('sd.hdf');
idx = sd.nameToIndex(sdID,'temperature');
sdsID = sd.select(sdID,idx);
data = sd.readData(sdsID);
sd.endAccess(sdsID);
sd.close(sdID);

Read a 2-by-3 portion of a data set.

import matlab.io.hdf4.*
sdID = sd.start('sd.hdf');
idx = sd.nameToIndex(sdID,'temperature');
sdsID = sd.select(sdID,idx);
data = sd.readData(sdsID,[0 0],[2 3]);
sd.endAccess(sdsID);
sd.close(sdID);

See Also