tail
Returns the last rows of an array or table.
Category: Language Fundamentals > Matrices and Arrays
Syntax
B = tail(A)
Returns up to the last 8 rows of A.
B = tail(A, k)
Returns up to the last k rows.
Description
tail is a quick way to inspect the end of a large table or column vector without printing everything. It is the counterpart of head, which returns the first rows.
For a vector the result keeps the orientation of the input.
Input arguments
A- Array or table.
k- Number of rows to keep. If
Ahas fewer rows, all of them are returned.
Output arguments
B- The trailing rows of
A, with all its columns.
Example
x = (1:10)';
tail(x, 3)
T = table((1:5)', (6:10)', 'VariableNames', {'a','b'});
tail(T, 2)
Output
ans = 3×1
8
9
10
ans = 2×2 table
a b
_ __
4 9
5 10