function out = table2timetableWithDimNames(in, rowTimes, dimNames)
%MATLAB Code Generation Library Function
% Convert a table to a timetable with specified dimension names
% Effectively the same as doing the following in-memory:
%     out = table2timetable(in,'RowTimes');
%     out.Properties.DimensionNames = dimNames; 

%   Copyright 2022 The MathWorks, Inc.
%#codegen

coder.inline('always');
coder.internal.prefer_const(rowTimes, dimNames);
data = cell(1, width(in));
for ii = coder.internal.indexInt(1):width(in)
    data{ii} = in{:, ii};
end
out = timetable(data{:},'RowTimes', rowTimes, ...
    'VariableNames', in.Properties.VariableNames, ...
    'DimensionNames', dimNames);
end