Main Content

istabular

Determine if input is table or timetable

Since R2021b

Description

tf = istabular(A) returns logical 1 (true) if A is either a table or a timetable, and logical 0 (false) otherwise.

This syntax is equivalent to tf = istable(A) || istimetable(A), but is more convenient.

Examples

collapse all

Create a table using the table function.

T = table([98;97.5;97.9;98.1;101],[120;111;119;117;118])
T=5×2 table
    Var1    Var2
    ____    ____

      98    120 
    97.5    111 
    97.9    119 
    98.1    117 
     101    118 

To confirm that T is either a table or a timetable, use the istabular function.

tf = istabular(T)
tf = logical
   1

Now convert T to a timetable.

TT = table2timetable(T,'RowTimes',hours(1:5))
TT=5×2 timetable
    Time    Var1    Var2
    ____    ____    ____

    1 hr      98    120 
    2 hr    97.5    111 
    3 hr    97.9    119 
    4 hr    98.1    117 
    5 hr     101    118 

The istabular function still returns 1 for TT.

tf = istabular(TT)
tf = logical
   1

However, the istable function returns 0 because TT is a timetable, not a table.

tf = istable(TT)
tf = logical
   0

Input Arguments

collapse all

Input variable.

Extended Capabilities

Version History

Introduced in R2021b