AllNetFields =
'NH0to90'
'SH0to90'
'HemDif0to90'
'Global0to90'
'AsymIndex0to90'
'NH0to14'
'SH0to14'
'HemDif0to14'
'Global0to14'
'AsymIndex0to14'
'NH14to30'
'SH14to30'
'HemDif14to30'
'Global14to30'
'AsymIndex14to30'
'NH30to49'
'SH30to49'
'HemDif30to49'
'Global30to49'
'AsymIndex30to49'
'NH49to90'
'SH49to90'
'HemDif49to90'
'Global49to90'
'AsymIndex49to90'
'GlobalAvg'
我只想在其中获取包含短语'HemDif'的字段。
但如果我尝试
>> AllNetFields{strfind(AllNetFields,'HemDif')}
Error using subsindex
Function 'subsindex' is not defined for values of class 'cell'.
我收到错误(我做错了)。有没有办法做到这一点?
答案 0 :(得分:2)
你可以这样做:
tmp = strfind(AllNetFields,'HemDif');
indexC = find(not(cellfun('isempty', tmp)));
% get strings containing 'HemDif'
AllNetFields{indexC}