%% Read HDF5 Dataset with Specified Spacing Between Indices
% Read data from a dataset, where the data is sampled at a specified spacing between the dataset indices along each dimension.
% First, display the metadata for a dataset /g4/lon from the HDF5 file example.h5. The variable in the dataset has one dimension with 36 elements.

h5disp('example.h5','/g4/lon')  

% Start reading from the location in startLoc and read variable data at intervals specified in stride. A value of 1 in stride accesses adjacent values in the corresponding dimension, whereas a value of 2 accesses every other value in the corresponding dimension, and so on.

startLoc = 1; 
count  = 18; 
stride = 2; 
subsetData  = h5read('example.h5','/g4/lon',startLoc,count,stride);

% Examine the output variable subsetData.

whos subsetData

% Copyright 2018 The MathWorks, Inc.