MATLAB: How to find cell match in matlab table and exctract data from table

cell arraydata importgendertable

Let's say I have a table. And a cell array, with
names = {'Smith, 'Williams}
Gender Age Smoker BloodPressure
______ ___ ______ _______________
Smith Male 38 true 124 93
Johnson Male 43 false 109 77
Williams Female 38 false 125 83
Jones Female 40 false 117 75
Brown Female 49 false 122 80
Now I would like to find the names match from the table and extract the values of other variables Gender, Age, Smoker, BloodPressure. I tried to use isfield, but this does not work and I am running out of ideas. I was plaaning to pull the row number and then all the column according to the row.
if isfield(Table,Names);
end
I tried finding

Best Answer

No explicit comparisons are necessary. It’s actually all in the documentation:
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);
names = {'Smith', 'Williams'};
T_result = T(names,:) % Get Data For Specific Patients
T_result =
Age Height Weight BloodPressure
___ ______ ______ _____________
Smith 38 71 176 124 93
Williams 38 64 131 125 83