%% Apply Function to Tall Vector
% Use matlab.tall.transform to build a tall array of zeros with attributes similar to another array.
%
% Create a tall table for the airlinesmall.csv data set. The data contains information about arrival and departure times of US flights. Extract the ArrDelay variable, which is a vector of arrival delays.

ds = tabularTextDatastore('airlinesmall.csv','TreatAsMissing','NA');
ds.SelectedVariableNames = {'ArrDelay' 'DepDelay'};
tt = tall(ds);
tX = tt.ArrDelay

%
% Write an anonymous function that creates an array of zeros with the same size and data type as the input.

zerosLike = @(in) zeros(size(in),'like',in);

%
% Use matlab.tall.transform to apply the zerosLike function to the vector of arrival delays. The result is a tall vector of the same size, but whose values are all zero.

s = matlab.tall.transform(zerosLike, tX)

% Copyright 2018 The MathWorks, Inc.