MATLAB parse or split string

In MATLAB I need to parse or split the following string 'E4'.  I want to be able to split 'C4' and 'C3' and compare the two numbers.  How can I do this?
Thanks
newtoperlpgmAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

yuk99Commented:
Are all your strings have the same format - one letter and one digit? In this case you can just use index to get the first letter or the digit.

string = 'E4';

string(1) will return 'E', and string(2) will return '4'. To convert string '4' to number you can use str2num or str2double function.

str2num(string(2)) will return number 4.

str2double is similar and can work with cell arrays.

If you have your strings in a cell array you can use cellfun function.

z = {'E4','C2','C3'}';
cellfun(@(x) str2num(x(2)), z)

Or

zstring = cell2mat(z);
str2num(zstring(:,2))

For more complicated parsing see documentation for functions strrep, strtok, regexp, regexprep, etc.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
newtoperlpgmAuthor Commented:
Great, thank you very much!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.