将表转换为元胞数组 您所在的位置:网站首页 matlab里cell 将表转换为元胞数组

将表转换为元胞数组

#将表转换为元胞数组| 来源: 网络整理| 查看: 265

打开实时脚本

创建一个包含五行和三个变量的表 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 = table2cell(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;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 将变量名称存储为字符向量元胞数组,即使这些名称以前是从字符串数组中指定的也是如此。



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有