MATLAB: Extracting number from a string

extractMATLABstring

How can I extract the number 1 from the string 'M1' ?

Best Answer

Here are two very simple methods:
>> str = 'M1';
>> sscanf(str,'M%d')
ans = 1
>> str(2)-'0'
ans = 1