How to convert a string into a specific numeric value.

7 ビュー (過去 30 日間)
Daniel Coughenour
Daniel Coughenour 2020 年 4 月 19 日
コメント済み: David Hill 2020 年 4 月 20 日
Hi, I need to convert a string into specific values increasing from 1 to 217 going in increments of 6.
I have a string that is consisting of numbers and letters and each number and letter needs to be changed into another number to create a vector. For example, 0=, 1=7, 2=13....a=61,b=67...z=217. I am not sure how to convert this string into a vector.

採用された回答

David Hill
David Hill 2020 年 4 月 19 日
b=zeros(1,122);
b(double('0123456789abcdefghijklmnopqrstqvwxyz'))=1:6:211;%with 36 elements, I get z=211
newString=b(yourString);
  3 件のコメント
David Hill
David Hill 2020 年 4 月 20 日
You should accept the answer to close this out.
David Hill
David Hill 2020 年 4 月 20 日
c=zeros(1,211);
c(1:6:211)='0123456789abcdefghijklmnopqrstqvwxyz';
yourString=char(c(newString));

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

製品


リリース

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by