DocumentationHelp Center
Number of table variables
W = width(T)
example
W = width(T)returns the number of variables in tableT.
T
width(T)是等效tosize(T,2).
width(T)
size(T,2)
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 tableAge 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 tableT.
W = 4
Tcontains4variables;widthdoes not count the row names.
4
width
The variable血压counts as one variable even though it contains two columns.
血压
Input table or array.
Variables in a table can have multiple columns, butwidth(T)only counts the number of variables.
This function fully supports tall arrays. For more information, seeTall Arrays.
This function fully supports code generation. For more information, seeCode Generation for Tables(MATLAB Coder).
This function fully supports GPU arrays. For more information, seeRun MATLAB Functions on a GPU(Parallel Computing Toolbox).
This function fully supports distributed arrays. For more information, seeRun MATLAB Functions with Distributed Arrays(Parallel Computing Toolbox).
height|numel|size
height
numel
size
A modified version of this example exists on your system. Do you want to open this version instead?
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:.
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office
Get trial now