MATLAB: How to convert characters array into integer number array

alphabetsMATLABnumberstxt

Hello,
I have a text file in which all the contents are characters like a,b,c,d…z . Can somone explain how to convert theses alphabets in txt file into numbers like a corresponds to1, b corresponds to 2 ,in the converted file.
Thanks.

Best Answer

str='I have a text file in which all the contents are characters like a,b,c,d…z . Can somone explain how to convert theses alphabets in txt file into numbers like a corresponds to1, b corresponds to 2 ,in the converted file'
s='a':'z'
for k=1:numel(s)
str=regexprep(str,s(k),num2str(k),'ignorecase');
end
str