举个例子看看:
有一个文本数据如下:
![](https://img-blog.csdnimg.cn/img_convert/f80951ccb826f82ed75e61a651c5422b.png)
% 第一行内容视为列名称
T = readtable('csv_table.txt')
![](https://img-blog.csdnimg.cn/img_convert/14ef930f57a8e271797dd4834f4e59e8.png)
% 访问其中的内容
LastName = T.LastName
![](https://img-blog.csdnimg.cn/img_convert/1c4c73e6aa1ebab182725ad21cd245a8.png)
% 数据部分
data_part = table2array(T(:, 3:end))
![](https://img-blog.csdnimg.cn/img_convert/b719a5f02b2c9f404ca6c91d1588e629.png)
拓展
% table 和 struct 互转
Tstruct = table2struct(T)
![](https://img-blog.csdnimg.cn/img_convert/2ed936a9ae5e0908a3c59185019ae0f2.png)
table_struct = struct2table(Tstruct)
![](https://img-blog.csdnimg.cn/img_convert/05692da148bac3b2ce493a0744703f1e.png)
% table 和 cell 互转
Tcell = table2cell(T)
![](https://img-blog.csdnimg.cn/img_convert/09944736ab41b6146688a9ca5c1781b2.png)
% 需要设置列名称
cell_table = cell2table(Tcell, 'VariableNames', T.Properties.VariableNames)
![](https://img-blog.csdnimg.cn/img_convert/1cbf9068e3f01de5e5652e6c34eee2cb.png)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)