timetable

Methods

Method Reference: timetable.splitvars

timetable: ttB = splitvars (ttA)
timetable: ttB = splitvars (ttA, vars)
timetable: ttB = splitvars (…, 'NewVariableNames', newNames)

Split multi-column variables of a timetable into one each.

ttB = splitvars (ttA) splits every multi-column variable, and every nested table, into one variable per column. ttB = splitvars (ttA, vars) splits only those named.

The new variables are named after the one they came from with a column number appended, unless 'NewVariableNames' gives them names. Splitting a variable that was merged does not bring back the units the merge discarded.

The row times are not a variable and cannot be split.

See also: mergevars, timetable

Source Code: timetable

splitvars is the other direction: a multi-column variable becomes one variable per column, named after it unless told otherwise.

 t0 = datetime (2024, 1, 1);
 TT = timetable ([12 34.1; 45 34.6; 23 35.0], (1:3)', 'RowTimes', ...
                 t0 + hours (0:2)', 'VariableNames', {'Cast', 'Station'});
 splitvars (TT).Properties.VariableNames
ans =
  1x3 cell array

    {'Cast_1'}    {'Cast_2'}    {'Station'}
 splitvars (TT, 'Cast', 'NewVariableNames', ...
            {'Depth', 'Salinity'}).Properties.VariableNames
ans =
  1x3 cell array

    {'Depth'}    {'Salinity'}    {'Station'}