主要内容

tall

Create tall array

描述

example

t=高大(ds)在数据存储顶部创建一个高大的数组ds.

  • 如果ds是表格数据的数据存储(所以读allmethods of datastore return tables or timetables), thentis a tall table or tall timetable, depending on what the datastore is configured to return. Tabular data is data that is arranged in a rectangular fashion with each row having the same number of entries.

  • Otherwise,tis a tall cell array.

example

t=高大(A)转换内存阵列A进入一个高大的阵列。底层数据类型t是相同的class(A). This syntax is useful when you need to quickly create a tall array, such as for debugging or prototyping algorithms.

在R2019B及更高版本中,您可以将内存阵列施入高阵列,以便在阵列上更有效的操作。转换为高大的数组后,Matlab®避免制作整个阵列的临时副本,并在较小的块中工作。这使您可以在阵列上执行更广泛的操作,而不耗尽内存。

例子

全部收缩

Convert a datastore into a tall array.

First, create a datastore for the data set. You can specify either a full or relative file location for the data set using数据存储(位置)创建数据存储。该locationargument can specify:

  • A single file, such as'airlinesmall.csv'

  • 具有相同扩展的几个文件,例如'*.csv'

  • 文件的整个文件夹,例如'C:\MyData'

tabulartextdatastore.also has several options to specify file and text format properties when you create the datastore.

创建一个数据存储区Airlinesmall.csv.data set. Treat'na'值作为缺失数据,以便它们被替换为NaN价值观。选择要使用的变量的小子集。

varnames = {'arrdelay','DepDelay','起源','ide'}; ds = tabularTextDatastore('airlinesmall.csv','TreatAsMissing','na',...'SelectedVariableNames', varnames);

采用tall为数据存储区中的数据创建高阵列。自数据以来dsis tabular, the result is a tall table. If the data is not tabular, thentallreleged comper array。

T = tall(ds)
T = MX4高表ARRDelay Depdelay Origin _____________ _____________________ 8 12 {'sjc'} {'san'} 21 20 {'san'} {'smf'} 1312 {'bur'} {'sjc'} 4 -1 {'lax'} {'lax'} 59 63 {'lax'} {'sjc'} 3 -2 {san'} {sfo'} 11-1 {'sea'} {'lax'} :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

您可以使用许多常见的MATLAB®运算符和功能与高阵列一起使用。要查看功能是否与高阵列合作,请检查Extended Capabilitiessection at the bottom of the function reference page.

将数据存储转换为高表,使用延迟计算计算其大小,然后执行计算并将结果返回在内存中。

First, create a datastore for theAirlinesmall.csv.data set. Treat'na'值作为缺失数据,以便它们被替换为NaN价值观。Set the text format of a few columns so that they are read as a cell array of character vectors. Convert the datastore into a tall table.

ds = tabularTextDatastore('airlinesmall.csv','TreatAsMissing','na'); ds.SelectedFormats{strcmp(ds.SelectedVariableNames,'tailnum')} ='%s'; ds.SelectedFormats{strcmp(ds.SelectedVariableNames,'取消代码')} ='%s';
T = tall(ds)
T = Mx29高大表年月DAYOFMONTH DAYOFWEEK DepTime CRSDepTime ArrTime CRSArrTime UniqueCarrier FlightNum TailNum ActualElapsedTime CRSElapsedTime开播ArrDelay DepDelay产地目标距离TaxiIn TaxiOut取消CancellationCode改行CarrierDelay WeatherDelay NASDelay SecurityDelay LateAircraftDelay ____ _____ __________ _________ _______ __________ _______ __________ _____________ _________ _______ _________________ ______________ _______ ________ _______________ _______ ________ ______ _______ _________ ________________ ________ ____________ ____________ ________ _____________ _________________ 1987 10 21 3 642 630 735 727 { 'PS'} 1503 { 'NA'} 53 57的NaN 8 12 { 'LAX'} { 'SJC'} 308楠楠0 {'Na'} 0 NaN NaN NaN NaN NaN 1987 10 26 1116116116116116116116116 {'NA'} 63 56 NAN 8 1 {'SJC'} {'BUR'} 296南纳0{'Na'} 0 NaN NaN NaN NaN NaN 1987 10 23 5 2055 2035 2218 2157 {'PS'} 1589 {'NA'} 83 82 NaN 21 20 {'SAN'} {'SMF'} 480纳米·0 {'Na'} 0纳米南楠南纳1987 10 23 5 1332 1320 1431 1418 {'ps'} 1655 {'na'} 59 58 nan 13 12 {'bur'} {'sjc'} {'sjc'} 296 NaN NaN 0 {'Na'} 0纳米南纳纳纳纳198710 22 4 629 630 746 742 {'ps'} 1702 {'na'} 77 72 NaN 4 -1 {'SMF'} {'LAX'} 373 NaN NaN 0 {'Na'} 0纳米南纳纳纳198710 28 3 1446 1343 1547 1448 {'ps'} 1729 {'na'} 61 65 NaN 59 63 {'LAX'} {'SJC'} 308 NaN NaN 0 {'Na'} 0纳米南纳南纳纳1987 108 4 928 930 1052 1049 {'ps'} 1763 {'na'} 84 79 naN 3 -2 {'san'} {'sfo'} 447 nan nan 0 {'na'} 0纳米南纳纳纳纳纳1987 1010 6 859 900 1134 1123 {'ps'} 1800 {'na'} 155 143 nan 11 -1 {'sea'} {'lax'} 954 nan naN 0 {'na'} 0纳米南纳南纳:::::::::::::::::::::::::::::::::::::::::::::::::::: : : : : : :

高表的显示表示MATLAB®尚不知道表中有多少行数据。

Calculate the size of the tall table. Since calculating the size of a tall array requires a full pass through the data, MATLAB does not immediately calculate the value. Instead, like most operations with tall arrays, the result is an unevaluated tall array whose values and size are currently unknown.

s =尺寸(t)
s = 1x2高大的双排矢量??

采用thegather函数要执行延迟计算并将结果返回到内存中。结果返回size是一个漫长的小小的1-2向量,适合内存。

sz = gather(s)
使用本地MATLAB会话评估高表达: - 通过1的1:1:在1.8秒评估中完成的2.1秒完成
sz =1×2123523 29

如果你使用gather在未发出的高阵列上,那么结果可能不适合内存。如果你不确定结果是否返回gather可以适合内存,使用gather(head(X))要么gather(tail(X))只将一小部分计算结果转换为内存。

创建一个随机数阵列,然后将其转换为高阵列。以这种方式从内存阵列中创建高阵列对于调试或原型设计新程序非常有用。内存阵列仍然受到正常内存约束的绑定,即使在将其转换为高大的数组之后,它也不能超过存储器的极限。

a = rand(100,4);ta =高(a)
tA = 100x4 tall double matrix 0.8147 0.1622 0.6443 0.0596 0.9058 0.7943 0.3786 0.6820 0.1270 0.3112 0.8116 0.0424 0.9134 0.5285 0.5328 0.0714 0.6324 0.1656 0.3507 0.5216 0.0975 0.6020 0.9390 0.0967 0.2785 0.2630 0.8759 0.8181 0.5469 0.6541 0.5502 0.8175 : : : : : : : :

在R2019B和稍后版本中,当您将内存阵列转换为高阵列时,您可以在数组上执行计算,而无需额外的存储器额外的数据。例如,此代码将大矩阵中的数据标准化,然后计算所有行和列的总和。此计算的内存版本需要不仅存储5GB阵列,而且还有足够的内存可用于创建数组的临时副本。

N = 25000; tA = tall(rand(N)); tB = tA - mean(tA); S = gather(sum(tB, [1,2]))
使用当地Matlab会话评估高表达: - 通过2的第1条:在6.1秒内完成 - 通过2:14秒的评估完成21秒
S = -3.0786e-10

Input Arguments

全部收缩

输入数据存储,指定为数据存储对象。看到数据存储for more information on creating a datastore object for your data set.

高阵列仅使用确定性的数据存储。也就是说,如果你使用on the datastore, reset the datastore with重启,然后再次读取数据存储,然后在两种情况下返回的数据必须相同。涉及不是确定性的数据存储的高阵列计算可以产生不可预测的结果。看到选择文件格式或应用程序的数据存储for more information.

例:ds = tabularTextDatastore('airlinesmall.csv')指定单个文件。

例:DS = tabulartextDataStore('*。CSV')specifies a collection of.csvfiles.

例:ds = spreadsheetDatastore('C:\MyData')指定电子表格文件的文件夹。

例:ds = datastore('hdfs:///data/')指定HDFS文件系统中的数据集。

In-memory variable, specified as an array.

Data Types:single||int8|int16|INT32.|int64|uint8|uint16|uint32|uint64|logical||timetable|string|细胞|分类|约会时间|duration|calendarDuration
Complex Number Support:Yes

Output Arguments

全部收缩

高大的数组,作为其中一种类型之一:

  • 转换数据存储时,tis a tall table or tall timetable for tabular datastores. Otherwise,tis a tall cell array.

  • When converting an in-memory array, the underlying data type oft是相同的class(A).

看到Deferred Evaluation of Tall Arraysfor information about how to effectively work with tall arrays.

提示

  • 看到Extend Tall Arrays with Other Products有关如何使用高阵列的信息:

    • Statistics and Machine Learning Toolbox™

    • Parallel Computing Toolbox™

    • MATLAB并行服务器™

    • Database Toolbox™

    • Matlab Compiler™

Extended Capabilities

Tall Arrays
Calculate with arrays that have more rows than fit in memory.

Introduced in R2016b