how do i split every digit of a string

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 日

1 投票

S = '1234'; % Say this is your string....
num = S - '0';
num(1)
num(2)
num(3)

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 11 月 24 日

1 投票

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'

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

タグ

質問済み:

2012 年 11 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by