Contenido principal

timetable2table

Convert timetable to table

Description

T = timetable2table(TT) converts the M-by-N timetable TT to an M-by-(N+1) table. The vector of row times from TT becomes the first variable in T.

The conversion discards the properties RowTimes, StartTime, SampleRate, TimeStep, and Events because they are properties for timetables only. The properties that remain after conversion are properties that tables and timetables have in common.

To write a timetable out to a text or spreadsheet file, use the writetimetable function.

example

T = timetable2table(TT,ConvertRowTimes=false) discards the vector of row times from TT.

example

Examples

collapse all

Create a timetable.

Time = datetime(["2025-12-18";"2025-12-19";"2025-12-20"]);
Temp = [37.3;39.1;42.3];
Pressure = [29.4;29.6;30.0];
Precip = [0.1;0.9;0.0];
TT = timetable(Time,Temp,Pressure,Precip)
TT=3×3 timetable
       Time        Temp    Pressure    Precip
    ___________    ____    ________    ______

    18-Dec-2025    37.3      29.4       0.1  
    19-Dec-2025    39.1      29.6       0.9  
    20-Dec-2025    42.3        30         0  

Convert TT to a table. The vector of row times from the timetable becomes a variable of the output table. So, where the timetable has a vector of row times and three variables, the table has four variables.

T = timetable2table(TT)
T=3×4 table
       Time        Temp    Pressure    Precip
    ___________    ____    ________    ______

    18-Dec-2025    37.3      29.4       0.1  
    19-Dec-2025    39.1      29.6       0.9  
    20-Dec-2025    42.3        30         0  

Display the properties of the input timetable. Because a timetable is a type of table, it has the properties that a table has, such as VariableNames. But it also has properties that are relevant only to timetables, such as RowTimes.

TT.Properties
ans = 
  TimetableProperties with properties:

             Description: ''
                UserData: []
          DimensionNames: {'Time'  'Variables'}
           VariableNames: {'Temp'  'Pressure'  'Precip'}
           VariableTypes: ["double"    "double"    "double"]
    VariableDescriptions: {}
           VariableUnits: {}
      VariableContinuity: []
                RowTimes: [3×1 datetime]
               StartTime: 18-Dec-2025
              SampleRate: NaN
                TimeStep: 1d
                  Events: []
        CustomProperties: No custom properties are set.
      Use addprop and rmprop to modify CustomProperties.

Display the properties of the output table. The timetable2table function discards the RowTimes, StartTime, SampleRate, TimeStep, and Events properties.

T.Properties
ans = 
  TableProperties with properties:

             Description: ''
                UserData: []
          DimensionNames: {'Row'  'Variables'}
           VariableNames: {'Time'  'Temp'  'Pressure'  'Precip'}
           VariableTypes: ["datetime"    "double"    "double"    "double"]
    VariableDescriptions: {}
           VariableUnits: {}
      VariableContinuity: []
                RowNames: {}
        CustomProperties: No custom properties are set.
      Use addprop and rmprop to modify CustomProperties.

Create a timetable.

Time = datetime(["2025-12-18";"2025-12-19";"2025-12-20"]);
Temp = [37.3;39.1;42.3];
Pressure = [29.4;29.6;30.0];
Precip = [0.1;0.9;0.0];
TT = timetable(Time,Temp,Pressure,Precip)
TT=3×3 timetable
       Time        Temp    Pressure    Precip
    ___________    ____    ________    ______

    18-Dec-2025    37.3      29.4       0.1  
    19-Dec-2025    39.1      29.6       0.9  
    20-Dec-2025    42.3        30         0  

Convert TT to a table and discard its row times.

T = timetable2table(TT,ConvertRowTimes=false)
T=3×3 table
    Temp    Pressure    Precip
    ____    ________    ______

    37.3      29.4       0.1  
    39.1      29.6       0.9  
    42.3        30         0  

Input Arguments

collapse all

Input timetable.

Output Arguments

collapse all

Output table. The table retains only the properties that tables and timetables have in common, such as descriptions, variable units, and variable names. For more information, compare the Properties sections of table and timetable.

Extended Capabilities

expand all

Thread-Based Environment
Run code in the background using MATLAB® backgroundPool or accelerate code with Parallel Computing Toolbox™ ThreadPool.

Version History

Introduced in R2016b