1

你能建议我一种方法来提取 Matlab 环境中表的特定列的名称(作为字符串)吗?

4

1 回答 1

3

这是答案: http ://se.mathworks.com/matlabcentral/answers/175423-how-to-extract-column-name-of-table-in-matlab

适用于:

f = figure('Position',[200 200 400 150]);
dat = rand(3); 
cnames = {'X-Data','Y-Data','Z-Data'};
rnames = {'First','Second','Third'};
t = uitable('Parent',f,'Data',dat,'ColumnName',cnames,... 
           'RowName',rnames,'Position',[20 20 360 100]); %from matlab help

get(t,'columnname')

ans = 

'X-Data'
'Y-Data'
'Z-Data'

对于表:

T = table(['M';'F';'M'],[45;32;34],...
         {'NY';'CA';'MA'},logical([1;0;0]),...
         'VariableNames',{'Gender' 'Age' 'State' 'Vote'}); %from matlab help
T.Properties.VariableNames

ans = 

'Gender'    'Age'    'State'    'Vote'
于 2015-02-05T09:59:37.737 回答