表Matlab中列的存在性测试

Mar*_*ary 3 matlab boolean matlab-table

我有下表,T:

      Hold       Min    Max 
    _________    ___    ____

     0.039248    0      0.05
     0.041935    0      0.05
     0.012797    0      0.05
    0.0098958    0      0.05
     0.014655    0      0.05
Run Code Online (Sandbox Code Playgroud)

如何测试表中的列是否存在?例如isfield(T,'Hold')返回0.Exist,isstruct也不行.我需要测试才能简单地返回真或假的结果.

exc*_*aza 5

请参阅:表格属性

例如:

LastName = {'Smith';'Johnson';'Williams';'Jones';'Brown'};
Age = [38;43;38;40;49];
Height = [71;69;64;67;64];
Weight = [176;163;131;133;119];
BloodPressure = [124 93; 109 77; 125 83; 117 75; 122 80];

T = table(Age,Height,Weight,BloodPressure,...
    'RowNames',LastName);

myquery = 'Age';
columnexists = ismember(myquery, T.Properties.VariableNames)
Run Code Online (Sandbox Code Playgroud)

返回:

columnexists =

     1
Run Code Online (Sandbox Code Playgroud)

  • 你可以在最后一行使用`ismember``columnexists = ismember(myquery,T.Properties.VariableNames)` (5认同)