how do i split every digit of a string

5 ビュー (過去 30 日間)
Sharen H
Sharen H 2012 年 11 月 24 日
i have a string as '1111' how to split its digit as
num(1)=1
num(2)=1
num(3)=1
num(4)=1
I will always have numbers only in the string
thanks in advance

採用された回答

Matt Fig
Matt Fig 2012 年 11 月 24 日
編集済み: Matt Fig 2012 年 11 月 24 日
S = '1234'; % Say this is your string....
num = S - '0';
num(1)
num(2)
num(3)
  1 件のコメント
Sharen H
Sharen H 2012 年 11 月 24 日
Thanks a lot

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 11 月 24 日
num = '1111'
then
num(1) would be '1'
If you need num(1) to be numeric 1 rather than the character 1, then
num = '1111' - '0'
  1 件のコメント
Sharen H
Sharen H 2012 年 11 月 24 日
Thank u

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by