How do I find a value in a vector and then create a new vector with those value?
古いコメントを表示
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.
採用された回答
その他の回答 (1 件)
Star Strider
2016 年 1 月 20 日
This is one possibility:
TS1='%@3Gb6';
[AlphaSt,AlphaEnd] = regexp(TS1, '[A-Za-z]+')
AlphaSt =
4
AlphaEnd =
5
2 件のコメント
Guillaume
2016 年 1 月 20 日
Actually, the simpler regex
pos = regexp(TS1, '[A-Za-z]');
would work better for the OP purpose.
Star Strider
2016 年 1 月 20 日
Thank you, Guillaume. I’m still learning the best ways to use regexp, and with your demonstrated expertise on this and several other topics, I value your Comments.
カテゴリ
ヘルプ センター および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!