timetable

Methods

Method Reference: timetable.removevars

timetable: ttB = removevars (ttA, vars)

Remove variables from a timetable.

ttB = removevars (ttA, vars) deletes the variables named, numbered, selected by a logical vector or picked out by a vartype.

The row times are not a variable and cannot be removed: a timetable keeps them whatever else goes. Removing every variable leaves a timetable with none, still carrying its row times and its time step, rather than an empty one.

Removing a variable of an eventtable that one of its three event properties names clears that designation, the name having nothing left to resolve to. Deleting the variable by assigning an empty matrix does the same.

See also: addvars, movevars, timetable

Source Code: timetable

removevars deletes variables. The row times are not a variable, so they cannot be removed: a timetable emptied of variables still carries its times and its time step.

 t0 = datetime (2024, 1, 1);
 TT = timetable ([12; 45; 23], [1; 2; 3], 'RowTimes', t0 + hours (0:2)', ...
                 'VariableNames', {'Depth', 'Cast'})
TT =
  3x2 timetable

            Time            Depth    Cast    
    ____________________    _____    ____    

    01-Jan-2024 00:00:00       12       1    
    01-Jan-2024 01:00:00       45       2    
    01-Jan-2024 02:00:00       23       3
 removevars (TT, 'Cast')
ans =
  3x1 timetable

            Time            Depth    
    ____________________    _____    

    01-Jan-2024 00:00:00       12    
    01-Jan-2024 01:00:00       45    
    01-Jan-2024 02:00:00       23

Take both away and the times remain.

 E = removevars (TT, {'Depth', 'Cast'});
 size (E)
ans =

   3   0
 E.Properties.TimeStep
ans =
  duration

   01:00:00