フィルターのクリア

How to split string with numbers?

41 ビュー (過去 30 日間)
José
José 2012 年 7 月 11 日
I've been reading some posts and i found some that could help me out! but for some reason it doesn't come out as i want it!
So here's the problem:
i have a string like this one '1,2,3,4;5,6,7,8;9,10,11,12' and i want to separate this string till i have 12 different strings.
i'm using this code:
g='1 2 3 4;5 6 7 8;9 10 11 12'; q=(regexp (g, ';', 'split'));
and i get this : q =
'1 2 3 4' '5 6 7 8' '9 10 11 12'
but then i want to separate it once more and i change ';' to ','
w=(regexp (q(1), ' ', 'split'));
w =
{1x4 cell}
So what am i doing wrong?
thanks for your help! José Matos

採用された回答

Tom
Tom 2012 年 7 月 11 日
Str='1,2,3,4;5,6,7,8;9,10,11,12';
Num=str2double(regexp(Str,'\d*','match')')
  1 件のコメント
José
José 2012 年 7 月 11 日
thanks that was really quick! and helpful!!

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

その他の回答 (0 件)

カテゴリ

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