MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

Location = removecats(Location,'County General Hospital');


Display the first eight elements of the categorical array, Location.


Location(1:8)


ans = 8x1 categorical array
St. Mary's Medical Center



St. Mary's Medical Center
St. Mary's Medical Center


St. Mary's Medical Center
St. Mary's Medical Center

After removing the category, County General Hospital, elements that previously
belonged to that category no longer belong to any category defined for Location.
Categorical arrays denote these elements as undefined.


Use the function isundefined to find observations that do not belong to any category.


undefinedIndex = isundefined(Location);


undefinedIndex is a 62-by-1 categorical array containing logical true ( 1 ) for all
undefined elements in Location.


Set Undefined Elements


Use the summary function to print the number of undefined elements in Location.


summary(Location)


St. Mary's Medical Center 24


38

The first element of Location belongs to the category, St. Mary's Medical Center.
Set the first element to be undefined so that it no longer belongs to any category.


Location(1) = '';
summary(Location)


St. Mary's Medical Center 23


39
Access Data Using Categorical Arrays
Free download pdf