width
Number of table variables
Syntax
Description
Examples
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
Input table or array.
Output Arguments
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
The
width function fully supports tall arrays. For more information,
see Tall Arrays.
This function fully supports code generation. For more information, see Code Generation for Tables (MATLAB Coder).
Starting in R2021b, the input can be an array, a table, or a timetable. In releases R2019b to R2021a, only tables and timetables are supported.
Refer to the usage notes and limitations in the C/C++ Code Generation section. The same usage notes and limitations apply to GPU code generation.
The width function fully supports
thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
The width function
fully supports GPU arrays. To run the function on a GPU, specify the input data as a gpuArray (Parallel Computing Toolbox). For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
The width function fully supports
distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).
Version History
Introduced in R2013bThe width function returns the number of variables of a table
or timetable, or the number of columns of an input array having any other data type.
In previous releases, calling width resulted in an error if the
input was not a table or timetable.
MATLAB Command
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.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.
Amerika
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)