summary(Location)
County General Hospital 39
St. Mary's Medical Center 24
VA Hospital 0
The patients observed at VA Hospital are deleted from Location, but VA Hospital is
still a category.
Use the removecats function to remove VA Hospital from the categories of
Location.
Location = removecats(Location,'VA Hospital');
Verify that the category, VA Hospital, was removed.
categories(Location)
ans = 2x1 cell array
{'County General Hospital' }
{'St. Mary's Medical Center'}
Location is a 63-by-1 categorical array that has two categories.
Delete Element
You can delete elements by indexing. For example, you can remove the first element of
Location by selecting the rest of the elements with Location(2:end). However, an
easier way to delete elements is to use [].
Location(1) = [];
summary(Location)
County General Hospital 38
St. Mary's Medical Center 24
Location is a 62-by-1 categorical array that has two categories. Deleting the first
element has no effect on other elements from the same category and does not delete the
category itself.
Check for Undefined Data
Remove the category County General Hospital from Location.
8 Categorical Arrays