tail
获取桌子,时间表或高阵列的底部行
Syntax
Description
Examples
Preview Table
Create a table that contains 100 rows and five variables.
load患者T = table(LastName,Gender,Age,Height,Weight); size(T)
ans =1×2100 5
Preview the last eight rows.
T2 = tail(T)
T2 =8×5 tableLastName Gender Age Height Weight _____________ __________ ___ ______ ______ {'Foster' } {'Female'} 30 70 124 {'Gonzales' } {'Male' } 48 71 174 {'Bryant' } {'Female'} 48 66 134 {'Alexander'} {'Male'} 25 69 171 {'Russell'} {'Male'} 44 69 188 {'Griffin'} {'Male'} 49 70 186 {'Diaz'}172 {'hayes'} {'男性'} 48 66 177
Preview Contents of Tall Table
创建一个高高的表格,然后预览底部的几行数据。
为AirlinesMall.CSV
data set. Select a subset of the variables to work with. Usetail
to extract the last few rows of data.
varnames = {“年”,'Month','arrdelay','DepDelay',“唯一载体”}; ds = tabularTextDatastore('airlinesmall.csv','TreatAsMissing','NA',...'SelectedVariableNames',varnames);T =高(DS)
T = Mx5 tall table Year Month ArrDelay DepDelay UniqueCarrier ____ _____ ________ ________ _____________ 1987 10 8 12 {'PS'} 1987 10 8 1 {'PS'} 1987 10 21 20 {'PS'} 1987 10 13 12 {'PS'} 1987 10 4 -1 {'PS'} 1987 10 59 63 {'PS'} 1987 10 3 -2 {'PS'} 1987 10 11 -1 {'PS'} : : : : : : : : : :
tt = tail(T)
tt = Mx5 tall table Year Month ArrDelay DepDelay UniqueCarrier ____ _____ ________ ________ _____________ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? : : : : : : : : : :
Collect the results into memory to view the data.
last_rows = gather(tt)
使用本地MATLAB会话评估高高的表达: - 通过1:Of 1:在1.1秒完成的1.4秒完成
last_rows=8×5 tableYear Month ArrDelay DepDelay UniqueCarrier ____ _____ ________ ________ _____________ 2008 12 14 1 {'DL'} 2008 12 -8 -1 {'DL'} 2008 12 1 9 {'DL'} 2008 12 -8 -4 {'DL'} 2008 12 15 -2 {'DL'} 2008 12 -15 -1 {'DL'} 2008 12 -12 1 {'DL'} 2008 12 -1 11 {'DL'}
检索高阵列中指定的行数
在高高的桌子中预览最后20行数据。
为AirlinesMall.CSV
data set. Select a subset of the variables to work with, and treat'NA'
values as missing data so thatdatast或者e
取代它们NaN
values. Usetail
to view the last 20 rows of data.
varnames = {“年”,'Month','arrdelay','DepDelay',“唯一载体”}; ds = tabularTextDatastore('airlinesmall.csv','TreatAsMissing','NA',...'SelectedVariableNames',varnames);T =高(DS)
T = Mx5 tall table Year Month ArrDelay DepDelay UniqueCarrier ____ _____ ________ ________ _____________ 1987 10 8 12 {'PS'} 1987 10 8 1 {'PS'} 1987 10 21 20 {'PS'} 1987 10 13 12 {'PS'} 1987 10 4 -1 {'PS'} 1987 10 59 63 {'PS'} 1987 10 3 -2 {'PS'} 1987 10 11 -1 {'PS'} : : : : : : : : : :
tt =尾(T, 20)
tt = Mx5 tall table Year Month ArrDelay DepDelay UniqueCarrier ____ _____ ________ ________ _____________ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? : : : : : : : : : :
Collect the results into memory to view the data.
b20 = gather(tt)
Evaluating tall expression using the Local MATLAB Session: - Pass 1 of 1: Completed in 0.43 sec Evaluation completed in 0.56 sec
b20=20×5桌Year Month ArrDelay DepDelay UniqueCarrier ____ _____ ________ ________ _____________ 2008 12 0 -4 {'CO'} 2008 12 -16 13 {'CO'} 2008 12 17 -3 {'CO'} 2008 12 3 -5 {'CO'} 2008 12 2 6 {'DL'} 2008 12 6 -2 {'DL'} 2008 12 37 35 {'DL'} 2008 12 -1 -6 {'DL'} 2008 12 39 12 {'DL'} 2008 12 -3 -6 {'DL'} 2008 12 -6 -1 {'DL'} 2008 12 -2 1 {'DL'} 2008 12 14 1 {'DL'} 2008 12 -8 -1 {'DL'} 2008 12 1 9 {'DL'} 2008 12 -8 -4 {'DL'} ⋮
Input Arguments
A
—输入数组
table|timetable
输入数组,指定为表或时间表。
Data Types:table
|timetable
k
—Number of rows to extract
scalar
Number of rows to extract, specified as a positive scalar integer. IfA
少于k
rows, thentail
returns all ofA
.
Output Arguments
B
— Requested rows
table | timetable
请求的行,作为表或时间表返回。数据类型B
is the same asA
.
Extended Capabilities
Tall Arrays
Calculate with arrays that have more rows than fit in memory.
This function fully supports tall arrays. For more information, seeTall Arrays.
您可以使用头
和tail
具有任何有效基础数据类型的高阵列(single
,double
,int8
,约会时间
,table
, 等等)。
If you are unsure whether the result returned bygather(A)
will fit in memory, then usegather(head(A))
或者gather(tail(A))
. These commands still fully evaluate the tall arrayA
,但仅返回记忆中结果的一小部分。
GPU Arrays
使用并行计算工具箱™在图形处理单元(GPU)上运行加速代码。
此功能完全支持GPU数组。万博1manbetx有关更多信息,请参阅Run MATLAB Functions on a GPU(Parallel Computing Toolbox).
Distributed Arrays
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.
此功能完全支持分布式数组。万博1manbetx有关更多信息,请参阅运行具有分布式数组的MATLAB功能(Parallel Computing Toolbox).
Version History
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
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.
Select a Web Site
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:.
您还可以从以下列表中选择一个网站:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- AméricaLatina(Español)
- Canada(English)
- United States(English)
欧洲
- Belgium(English)
- 丹麦(English)
- Deutschland(德意志)
- España(Español)
- Finland(English)
- 法国(Français)
- 爱尔兰(English)
- 意大利(Italiano)
- Luxembourg(English)
- Netherlands(English)
- 挪威(English)
- Österreich(德意志)
- Portugal(English)
- Sweden(English)
- 瑞士
- 英国(English)