用Matlab访问不同形式的表数据
我有如下表格用Matlab访问不同形式的表数据,matlab,dataformat,Matlab,Dataformat,我有如下表格 LastName = {'Smith';'Johnson';'Williams';'Jones';'Brown'}; Age = [38;43;38;40;49]; FirstName = {'Amanda' ;'Brenda';'Carl'; 'Denis'; 'Ethan'}; Something = {'String1' ;'String2';'String2'; 'String1'; 'String5'}; Weight = [176;163;131;133;119]; F
LastName = {'Smith';'Johnson';'Williams';'Jones';'Brown'};
Age = [38;43;38;40;49];
FirstName = {'Amanda' ;'Brenda';'Carl'; 'Denis'; 'Ethan'};
Something = {'String1' ;'String2';'String2'; 'String1'; 'String5'};
Weight = [176;163;131;133;119];
FavoriteColor = {'blue' ;'red' ;'yellow'; 'orange' ;'colorblind' };
T = table(Age,FirstName,Weight,FavoriteColor,Something,'RowNames',LastName)
T.FavoriteColor= categorical(T.FavoriteColor);
T.Something= categorical(T.Something);
当我使用
A=T(:,5);
A=T.Something;
我得到一个变量a,它也是一个表。但是当我使用
A=T(:,5);
A=T.Something;
我得到了一个变量a,它是一个分类值,就像列a一样。我想使用循环,所以我需要使用带索引的第一个循环,但我想在第二个循环中得到结果。我应该怎么做?使用
a=T{:,5}代码>解决了问题 不同的索引语法将导致不同的输出类型。具体阅读