tail
获取数组或表的底行
说明
示例
创建一个有 100 行的矩阵,并显示矩阵的最后八行。
如果不指定输出参量,tail
不会返回值。它只显示矩阵的底部。
A = repmat((1:100)',1,4); tail(A)
93 93 93 93 94 94 94 94 95 95 95 95 96 96 96 96 97 97 97 97 98 98 98 98 99 99 99 99 100 100 100 100
从包含 1468 行的文件创建一个表。
T = readtable("outages.csv","TextType","string"); size(T)
ans = 1×2
1468 6
显示最后三行。如果不指定输出参量,tail
不会返回值。它只显示表的底部。
tail(T,3)
Region OutageTime Loss Customers RestorationTime Cause ___________ ________________ ______ __________ ________________ _________________ "MidWest" 2011-01-02 14:41 364.24 2.8432e+05 2011-01-04 04:43 "winter storm" "SouthEast" 2013-12-20 19:52 2.3096 1038.2 2013-12-20 23:29 "thunder storm" "SouthEast" 2011-09-14 11:55 45.042 11835 2011-09-14 13:28 "equipment fault"
通过从电子表格中读取数据来创建一个表。显示该表的大小,根据显示它有 1468 行。
T = readtable("outages.csv","TextType","string"); size(T)
ans = 1×2
1468 6
返回另一个包含 T
的最后八行的表。
T2 = tail(T)
T2=8×6 table
Region OutageTime Loss Customers RestorationTime Cause
___________ ________________ ______ __________ ________________ __________________
"West" 2010-12-04 12:09 245.72 1.074e+05 2010-12-07 13:05 "winter storm"
"West" 2013-01-05 05:52 0 0 2013-01-05 06:08 "attack"
"West" 2010-12-01 04:12 369.43 NaN 2010-12-01 04:28 "energy emergency"
"West" 2011-11-21 16:51 0 0 2011-11-21 16:55 "attack"
"SouthEast" 2011-01-03 05:52 NaN 2.7596e+05 2011-01-06 05:25 "winter storm"
"MidWest" 2011-01-02 14:41 364.24 2.8432e+05 2011-01-04 04:43 "winter storm"
"SouthEast" 2013-12-20 19:52 2.3096 1038.2 2013-12-20 23:29 "thunder storm"
"SouthEast" 2011-09-14 11:55 45.042 11835 2011-09-14 13:28 "equipment fault"
输入参数
输入数据,指定为数组、元胞数组、表或时间表。
要提取的行数,指定为正整数。如果 A
少于 k
行,则 tail
将返回 A
的所有行。
扩展功能
tail
函数完全支持 tall 数组。有关详细信息,请参阅 tall 数组。
您可以将 head
和 tail
用于任何具有有效基本数据类型(single
、double
、int8
、datetime
、table
等)的 tall 数组。
如果您不确定 gather(A)
返回的结果是否能够完全存入内存,请使用 gather(head(A))
或 gather(tail(A))
。这两个命令还是会完全计算 tall 数组 A
,但只将一小部分结果返回到内存中。
tail
函数完全支持 GPU 数组。要在 GPU 上运行该函数,请将输入数据指定为 gpuArray
(Parallel Computing Toolbox)。有关详细信息,请参阅在 GPU 上运行 MATLAB 函数 (Parallel Computing Toolbox)。
此函数完全支持分布式数组。有关详细信息,请参阅使用分布式数组运行 MATLAB 函数 (Parallel Computing Toolbox)。
版本历史记录
在 R2016b 中推出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.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- 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)