function X = sampleTable2NumericArray(T)
%SAMPLETABLE2NUMERICARRAY
%
%Helper to convert a table produced by sdo.sample() to a fully numeric
%format.
%
%Table can have variables that are double, logical, or strings. Variables
%are scalar. 
%
%String variables are converted into ordinal values. Ordinal
%value is defined by the unique string value the variable takes on.
%
%Logical values are auto converted to double by assigning the logical value
%to an element in a double array.
%
%  X = sampleTable2NumericArray(T)
%
%  Inputs
%    T - table
%
%  Ouputs
%    X - double array, same size as T.

%  Copyright 2022 The MathWorks, Inc.

nVar = size(T,2);
nRow = size(T,1);
X = nan(nRow,nVar);
for ctVar=1:nVar
    rvalues = T{:,ctVar};
    if isstring(rvalues)
        [~,~,X(:,ctVar)] = unique(rvalues);
    else
        X(:,ctVar) = rvalues;
    end
end
end

% LocalWords:  sdo Ouputs
