I have a large cell array in Matlab (imported from Excel) containing numbers and strings. Let's say the string part looks like this, just bigger with many columns and lines:
Table{1,1} = 'string A'
Table{2,1} = 'string B'
Table{3,1} = 'string B'
And the number part looks like this just bigger:
Table{1,2} = 5;
Table{2,2} = 10;
Table{3,2} = 15;
I am aware that there are disadvantages of working with arrays (right?), so I consider converting EVERYTHING to a numeric matrix by replacing the strings with numbers. (Possibly as a data set with headings - if you don't advise against that?)
My problem is that I have A LOT of different string entries, and I want to automatically assign a number to each entry, e.g. 1 for 'string A', 2 for 'string B' etc., such that:
Matrix(1,1) = 1
Matrix(2,1) = 2
Matrix(3,1) = 2
etc.
and for the numbers simply:
Matrix(1,2) = Table{1,2};
Matrix(2,2) = Table{2,2};
Matrix(3,2) = Table{3,2};
For the strings, I cannot assign the numbers by individual code for each string, because there are so many different string entries. Is there a way to "automate" it?
I am aware of this help site, https://ch.mathworks.com/help/matlab/matlab_prog/converting-from-string-to-numeric.html, but haven't found anything else helpful. How would you do it?