Main Content

width

Number of table variables

Description

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

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

example

Examples

collapse all

Create a table, T.

LastName = ["Smith";"Chen";"Williams";"Jones";"Lopez"];
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  
    Chen        43       69       163       109     77  
    Williams    38       64       131       125     83  
    Jones       40       67       133       117     75  
    Lopez       49       64       119       122     80  

Return the number of variables in table T. The variable BloodPressure counts as one variable even though it contains two columns. The set of row names does not count as a variable.

w = width(T)
w = 
4

Input Arguments

collapse all

Input table or array.

Output Arguments

collapse all

Number of variables, returned as a positive integer scalar.

A table variable can be a vector, matrix, or multidimensional array. Even if a table variable is an array with multiple columns, the width function counts it as one table variable.

Extended Capabilities

expand all

Version History

Introduced in R2013b

expand all

See Also

| |