Name Size Bytes Class Attributes
Age 100x1 800 double
Diastolic 100x1 800 double
Gender 100x1 12212 cell
Height 100x1 800 double
LastName 100x1 12416 cell
Location 100x1 15008 cell
SelfAssessedHealthStatus 100x1 12340 cell
Smoker 100x1 100 logical
Systolic 100x1 800 double
Weight 100x1 800 double
Create Categorical Arrays from Cell Arrays of Character Vectors
Gender and Location contain data that belong in categories. Each cell array contains
character vectors taken from a small set of unique values (indicating two genders and
three locations respectively). Convert Gender and Location to categorical arrays.
Gender = categorical(Gender);
Location = categorical(Location);
Search for Members of a Single Category
For categorical arrays, you can use the logical operators == and ~= to find the data that is
in, or not in, a particular category.
Determine if there are any patients observed at the location, 'Rampart General
Hospital'.
any(Location=='Rampart General Hospital')
ans = logical
0
There are no patients observed at Rampart General Hospital.
Search for Members of a Group of Categories
You can use ismember to find data in a particular group of categories. Create a logical
vector for the patients observed at County General Hospital or VA Hospital.
VA_CountyGenIndex = ...
ismember(Location,{'County General Hospital','VA Hospital'});
Access Data Using Categorical Arrays