%% Specify Read Size for ArrayDatastore
% Create a datastore for a MAT-file variable, and then read data from the file with different ReadSize values.
% Load the MAT-file BostonWeatherData.mat into the workspace.

load 'BostonWeatherData.mat'

% Create a datastore for the weatherData variable. Set ReadSize to 10 rows. The value of ReadSize determines how many rows of data are read from the datastore with each call to the read function. Set 'OutputType' to 'same' to return the same data types as the input array.

arrds = arrayDatastore(weatherData,"ReadSize",10, "OutputType","same")

% Read the data from the datastore.

data1 = read(arrds)

% Set the ReadSize property value to 30 and read from the datastore. The second call to the read function reads the next 30 rows from the datastore.

arrds.ReadSize = 30;

% Read the data from the datastore.

data2 = read(arrds)

% Copyright 2020 The MathWorks, Inc.