table

Methods

Method Reference: table.height

table: H = height (tbl)

Number of rows in table.

H = height (tbl) returns the number of rows in the table tbl as a scalar. It is the equivalent of size (tbl, 1).

For an empty table, or a table created with zero rows, height returns 0. The presence of row names does not affect the result.

Source Code: table

Example: 1

height counts rows, independent of how many columns each variable spans. Here BloodPressure occupies two columns, yet the table still has 5 rows.

 Age = [38; 43; 38; 40; 49];
 BloodPressure = [124, 93; 109, 77; 125, 83; 117, 75; 122, 80];
 T = table (Age, BloodPressure)
T =
  5x2 table

    Age    BloodPressure    
    ___    _____________    

     38        124    93    
     43        109    77    
     38        125    83    
     40        117    75    
     49        122    80
 height (T)
ans = 5

It is the row count you index against, so height is the natural bound for a loop or a final-row reference.

 T(height (T), :)
ans =
  1x2 table

    Age    BloodPressure    
    ___    _____________    

     49        122    80