%% Output Table with Different Variables
% Use the 'OutputsLike' option to return a table from matlab.tall.transform that has different variables from the input table.
%
% Create a tall table with two variables of random values.

T = tall(table(rand(1e6,1),rand(1e6,1)))

%
% The function tableDiff calculates the difference between two input table variables and adds the result as a new variable in the table. Display the contents of the file.

type tableDiff

%
% Use matlab.tall.transform to apply the tableDiff function to each block of data in T. Since the output table has different variables from the input table, use the 'OutputsLike' name-value pair to supply a prototype table with similar variables as the output (three variables with the default names Var1, Var2, and Var3).

Z = matlab.tall.transform(@tableDiff, T, 'OutputsLike', {table(1,1,1)})

%
% Copyright 2018 The MathWorks, Inc.