timetable.tail
timetable: tail (tt)
timetable: tail (tt, k)
timetable: out = tail (tt, k)
Display or return the last k rows of a timetable.
tail (tt) displays the last eight rows of tt, or
all of them if it has fewer. tail (tt, k) displays
the last k instead. k must be a real, nonnegative,
integer scalar value; a k of zero displays no rows at all rather
than raising.
out = tail (tt, k) returns those rows in a
new timetable instead of displaying them. If k is omitted or
empty it defaults to eight.
The rows come back in the order the timetable holds them, and they are the last rows rather than the latest ones. The time step is read afresh from the row times that are kept.
See also: head, sortrows, timetable
Source Code: timetable
tail shows the last rows of a timetable, eight of them unless told otherwise.
t0 = datetime (2024, 1, 1); Temp = 15 + (1:12)' / 2; TT = timetable (Temp, 'RowTimes', t0 + hours (0:11)'); tail (TT, 4)
Time Temp
____________________ ____
01-Jan-2024 08:00:00 19.5
01-Jan-2024 09:00:00 20
01-Jan-2024 10:00:00 20.5
01-Jan-2024 11:00:00 21
The time step is read afresh from the rows that are kept, so the tail of a timetable whose spacing changes partway may not be regular even when the head of it is.
t0 = datetime (2024, 1, 1);
G = timetable ((1:4)', 'RowTimes', t0 + hours ([0 1 2 9])', ...
'VariableNames', {'Reading'});
head (G, 3).Properties.TimeStep
ans = duration 01:00:00
tail (G, 3).Properties.TimeStep
ans = duration NaN sec