Hi all, I want to assign variables to my single column table data of strings in matlab
1 view (last 30 days)
say I have this data in a table type: b= 'come' 'go' 'see' 'west' 'done'
and I want assign letters from A-Z to each member. so I'll have something like 'come' = A. but since the data is more than 26 rows, I'd preferably have 'come'=A1, 'go'=B1 and the last string = Zn. Any inputs would be appreciated!
Saurabh Gupta on 31 Jul 2017
As I understand, you have a column vector of unique strings and you want to determine an index in the form of "Axx to Zxx" for each of these strings based on their indices in the vector. If my understanding is correct, then I think all you need is some modulo arithmetic and integer division .
For example, lets say 'come' is at index 'i' in the vector. Then the following command will give you an index of the required form.
>> newIndex = [char(64 + mod(i,26)), num2str(idivide(i,uint32(26)))]
Note that it is only a suggestive example to demonstrate the idea. You may need to play around with it. Hope this helps!