height — Return the number of table rows or array rows.
height reads the first visible dimension from array, table, timetable, resident, or distributed shape metadata and returns an exact host double scalar.
Syntax
n = height(A)Inputs
A- Type
Any- Required
- Yes
- Description
- Value whose MATLAB-visible dimensions are inspected.
Returns
n- Type
NumericScalar- Description
- Exact extent of the first MATLAB-visible dimension.
Errors
RunMat:height:ResultNotExactDouble- When
- The row count cannot be represented exactly by the documented double output.
- Message
height: result exceeds exact double range
RunMat:height:InternalError- When
- Value, tabular, resident, or distributed shape metadata is invalid.
- Message
height: invalid shape metadata
RunMat:height:TooManyOutputs- When
- More than one output is requested.
- Message
height: too many output arguments
Rows in arrays and tabular values
height(A) returns the first MATLAB-visible dimension as a host double scalar. For a table or timetable, that dimension is the number of rows. For an ordinary array, height(A) is equivalent to size(A, 1).
Numeric, complex, logical, character, string, cell, datetime, duration, categorical, sparse, and object arrays use their outer shape. The element class and values do not affect the result.
Structural metadata
All eight fixed-width integer classes use the same structural path. Integer payloads are not converted or inspected. Table variables may contain several columns; their row counts still determine table height.
gpuArray and distributed inputs use validated handle metadata. height launches no kernel, calls no acceleration provider, and transfers no payload. The result is returned on the host at a fusion boundary.
RunMat reports an error if the row count cannot be represented exactly by the documented double result instead of rounding the structural value.
Examples
Count matrix rows
A = zeros(5, 3, 'uint64');
n = height(A)Expected output:
n = 5Count table rows
id = [101; 102; 103];
score = [8; 5; 9];
T = table(id, score);
n = height(T)Expected output:
n = 3Inspect an empty rectangular array
A = zeros(0, 7);
n = height(A)Expected output:
n = 0Read a resident row count
G = gpuArray(ones(128, 4));
n = height(G)Expected output:
n = 128Using height with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how height changes the result.
Run a small height example, explain the result, then change one input and compare the output.
FAQ
How is height related to size?⌄
For arrays, tables, and timetables, height(A) returns the same count as size(A, 1).
Does height inspect table variables?⌄
It validates tabular metadata and returns the shared row count. It does not inspect the values stored in each row.
Does height gather a gpuArray?⌄
No. The resident handle carries the first-dimension extent.
Where does the result live?⌄
The result is a host double scalar because it describes shape metadata rather than array payload.
Related Array functions
Introspection
iscolumn · isempty · ismatrix · isrow · isscalar · isvector · length · ndims · numel · size · width
Accumulation
Sorting Sets
argsort · intersect · ismember · ismembertol · issorted · issortedrows · setdiff · setxor · sort · sortrows · union · unique
Shape
blkdiag · cat · circshift · diag · flip · fliplr · flipud · horzcat · ipermute · kron · permute · repelem · repmat · reshape · rot90 · shiftdim · squeeze · toeplitz · tril · triu · vertcat
Creation
colon · createArray · empty · eye · false · full · inf · int16.empty · int32.empty · int64.empty · int8.empty · linspace · logspace · magic · meshgrid · nan · ndgrid · nonzeros · ones · peaks · rand · randi · randn · randperm · range · sparse · spdiags · speye · spones · sprand · true · uint16.empty · uint32.empty · uint64.empty · uint8.empty · zeros
Combinatorics
Binning
Grouping
Source you can read
Every RunMat function's source is public. Read exactly how height is executed, line by line, in Rust.
- View the source for height in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.