This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

width

Number of table variables

Syntax

W = width(T)

Description

example

W = width(T) returns the number of variables in table T.

width(T) is equivalent to size(T,2).

Examples

collapse all

Create a table, T.

LastName = {'Smith';'Johnson';'Williams';'Jones';'Brown'};
Age = [38;43;38;40;49];
Height = [71;69;64;67;64];
Weight = [176;163;131;133;119];
BloodPressure = [124 93; 109 77; 125 83; 117 75; 122 80];

T = table(Age,Height,Weight,BloodPressure,'RowNames',LastName)
T=5×4 table
                Age    Height    Weight    BloodPressure
                ___    ______    ______    _____________

    Smith       38       71       176       124     93  
    Johnson     43       69       163       109     77  
    Williams    38       64       131       125     83  
    Jones       40       67       133       117     75  
    Brown       49       64       119       122     80  

Find the number of variables in table T.

W = width(T)
W = 4

T contains 4 variables; width does not count the row names.

The variable BloodPressure counts as one variable even though it contains two columns.

Input Arguments

collapse all

Input table, specified as a table.

Variables in a table can have multiple columns, but width(T) only counts the number of variables.

Extended Capabilities

See Also

| |

Introduced in R2013b