% This function is part of the NMSM Pipeline, see file for full license.
%
% This function takes a string array of column names in order, a 1D array
% of time points and a 2D array of data. The first dimension of the 1D and
% 2D arrays must match.
%
% (Array of string, Array of double, matrix of double, string) -> (None)
% Print results of optimization to console or file
function writeToSto(columnLabels, timePoints, data, outfile)
import org.opensim.modeling.TimeSeriesTable
import org.opensim.modeling.STOFileAdapter
table = TimeSeriesTable();
table.setColumnLabels(stringArrayToStdVectorString(columnLabels));
for i=1:length(timePoints)
table.appendRow(timePoints(i), doubleArrayToRowVector(data(i, :)))
end
STOFileAdapter.write(table, outfile)
end