MATLAB 帮助中心
将表转换为元胞数组
C = table2cell(T)
C = table2cell(T) 将表或时间表 T 转换为元胞数组 C。T 中的每个变量都会成为 C 中的元胞列。
T
C
输出 C 不包括 T.Properties 中的表属性。
T.Properties
如果 T 是包含行名称的表,则 C 不包含行名称。
如果 T 是时间表,则 C 不包括行时间。
示例
全部折叠
创建一个包含五行和三个变量的表 T。
T = table(categorical(["Y";"Y";"N";"N";"N"]),[38;43;38;40;49],... [124 93;109 77; 125 83; 117 75; 122 80],... 'VariableNames',["Smoker" "Age" "BloodPressure"],... 'RowNames',["Chang" "Brown" "Ruiz" "Lee" "Garcia"])
T=5×3 table Smoker Age BloodPressure ______ ___ _____________ Chang Y 38 124 93 Brown Y 43 109 77 Ruiz N 38 125 83 Lee N 40 117 75 Garcia N 49 122 80
将 T 转换为元胞数组。
C=5×3 cell array {[Y]} {[38]} {[124 93]} {[Y]} {[43]} {[109 77]} {[N]} {[38]} {[125 83]} {[N]} {[40]} {[117 75]} {[N]} {[49]} {[122 80]}
C 为 5×3 元胞数组。
将表属性 T.Properties.VariableNames 与 C 垂直串联,以包含元胞数组的列标题。
T.Properties.VariableNames
[T.Properties.VariableNames;C]
ans=6×3 cell array {'Smoker'} {'Age'} {'BloodPressure'} {[Y ]} {[ 38]} {[ 124 93]} {[Y ]} {[ 43]} {[ 109 77]} {[N ]} {[ 38]} {[ 125 83]} {[N ]} {[ 40]} {[ 117 75]} {[N ]} {[ 49]} {[ 122 80]}
T.Properties.VariableNames 将变量名称存储为字符向量元胞数组,即使这些名称以前是从字符串数组中指定的也是如此。
输入表,指定为表或时间表。
如果 T 为 m×n 表或时间表,则 C 为 m×n 元胞数组。
m
n
全部展开
table2cell 函数完全支持 tall 数组。有关详细信息,请参阅 tall 数组。
table2cell
此函数完全支持代码生成。有关详细信息,请参阅表的代码生成 (MATLAB Coder)。
backgroundPool
ThreadPool
此函数完全支持分布式数组。有关详细信息,请参阅使用分布式数组运行 MATLAB 函数 (Parallel Computing Toolbox)。
在 R2013b 中推出
cell2table | table2array | table2struct | table
cell2table
table2array
table2struct
table
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 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
欧洲
亚太
联系您当地的办事处