Main Content

matlab.io.hdf4.sd.readData

Namespace: 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 dataset identified by sdsID.

data = readData(sdsID,start,count) reads a contiguous hyperslab of data from the dataset 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 dataset dimension.

data = readData(sdsID,start,count,stride) reads a strided hyperslab of data from the dataset 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 dataset.

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 dataset.

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