I have the following line in matlab
V= 'abcdefghijklmnñopqrstuvwxyz';
Then I have a 9 character word consisting of characters from my "V" alphabet.
k = 'peligroso';
I want to create a square matrix (3x3) with the indices of my word "k" according to my alphabet, this will be the way out. (Note that the range I'm considering is from 0 to 26, so the "a" char has index 0)
16 4 11
8 6 18
15 19 15
My code for this:
K = [findstr(V, k(1))-1 findstr(V, k(2))-1 findstr(V, k(3))-1;findstr(V, k(4))-1 findstr(V, k(5))-1 findstr(V, k(6))-1; findstr(V, k(7))-1 findstr(V, k(8))-1 findstr(V, k(9))-1];
But I think there should be a more elegant solution to achieve the same, any ideas?
PS: I do not use ASCII values ​​since char '-' must be inside my alphabet
source share