【问题标题】:How to extract column name of table in matlab如何在matlab中提取表的列名
【发布时间】:2015-02-05 07:54:27
【问题描述】:

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

【问题讨论】:

标签: matlab extract columnname


【解决方案1】:

答案如下: 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'

【讨论】:

    猜你喜欢
    • 2021-02-21
    • 1970-01-01
    • 2022-06-23
    • 2021-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-13
    • 2020-04-04
    相关资源
    最近更新 更多