MATLAB: How to find a value in a vector and then create a new vector with those value

homeworknumerical values

I am having an issue with the following task. How do I create a vector that shows the position of the alphabetic characters as numerical values? Create a vector Alphas that has the numeric positions of all alphabetic characters in TS1. For Example: TS1='%@3Gb6' returns Alphas=[4 5]. I am using the Matlab R2015b software.

Best Answer

>> TS1='%@3Gb6';
>> find(iswithin(TS1,'A','z'))
ans =
4 5
>>
>> type iswithin
function flg=iswithin(x,lo,hi)
% returns T for values within range of input
% SYNTAX:
% [log] = iswithin(x,lo,hi)
% returns T for x between lo and hi values, inclusive
% Utility routine courtesy dpbozarth (aka dpb)
flg= (x>=lo) & (x<=hi);
>>
ERRATUM
As noted, forgot there were some characters between the lower- and upper-case ones that will screw up count/position if not accounted for.
find(iswithin(TS1,'A','z') & isletter(TS1))
does work albeit now it may be as simple as to write the regular expression expression.
And, DOH!
find(isletter(TS1))
actually is all that's needed.