MATLAB: Question on CATEGORICAL and Help files

categorical

Well, not a question as much as a comment. I'm finding the Help files a bit too brief for this class. Does any one else agree?
For example:
  • How to preallocate a categorical array? I'm dealing with 13,000,000 records and moving the data into variables in 32 bit machine hits the memory limit quickly. Preallocation is critical inthis application.
  • How to turn a categorical array back into numbers of characters? Hehe, trying to use the variable editor and paste the categorical data into a column of another (non categorical) variable, froze the machine (or was it a crash?).

Best Answer

I usually preallocate tables or categoricals dynamically by running my loop backward
T = table;
for ii = 10:-1:1;
T(ii,:) = array2table(rand(1,4));
end
To your second question:
c = categorical({'red';'red';'blue'})
cellstr(c)