2014-01-15 76 views

回答

3

您可以使用fieldnames,然後strfind

a.OneTwoThree = 4; %// first field name 
a.AnotherField = 'hello'; %// second example field name 

測試所有的字段名稱:

names = fieldnames(a); %// gives all field names 
findTwo = ~isempty(strfind(names,'Two')); 

只測試第一場:

names = fieldnames(a); %// gives all field names 
findTwo = ~isempty(strfind(names{1},'Two'));