%% Create Datastore Object Using Custom Datastore And Read Data
% Use custom datastore to preview and read your proprietary data into MATLAB for serial processing.
% This example uses a simple data set to illustrate a workflow using your custom datastore. The data set is a collection of 15 binary (.bin) files where each file contains a column (1 variable) and 10000  rows (records) of unsigned integers.

dir('*.bin')

% Create a datastore object using the MyDatastore function. For implementation details of MyDatastore, see the example Build Datastore to Read Binary Files.

folder = fullfile('*.bin'); 
ds = MyDatastore(folder); 

% Preview the data from the datastore.

preview(ds)

% Read the data in a while loop and use the  hasdata method to check if more data is available to read.

while hasdata(ds)
    data = read(ds);
    % do something
end

% Reset the datastore to its initial state and read the data from the start of the datastore.

reset(ds);
data = read(ds);

% Alternatively, if your data collection fits in memory, then read all the data in the datastore. Since the folder contains  15  files with  10000  records in each file, the size of the output should be  150000  records.

dataAll = readall(ds);
whos dataAll