Convert single string with many numbers to vector
29 ビュー (過去 30 日間)
古いコメントを表示
I have the following string
hue = '10 20 30 40 50';
That I want to turn into a vector of those 5 values
hue_vec = [10 20 30 40 50];
How can I do this? Thanks in advance!
0 件のコメント
採用された回答
madhan ravi
2019 年 7 月 31 日
hue_vec = str2double(regexp(hue,'\d+','match'))
1 件のコメント
madhan ravi
2019 年 7 月 31 日
If you have decimals then the expressions would be:
hue_vec = str2double(regexp(hue,'\d*[\.]?\d*','match'))
その他の回答 (3 件)
参考
カテゴリ
Help Center および File Exchange で Numeric Types についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!