how can remove words and split in cellarray in matlab
1 回表示 (過去 30 日間)
古いコメントを表示
for example x={'100614,Peter Beadle,131542'}; i want x= [100614,131542] my dataset have 408934 record like 'x'
0 件のコメント
採用された回答
Paolo
2018 年 6 月 10 日
編集済み: Paolo
2018 年 6 月 10 日
For input:
x = {'100614,Peter Beadle,131542'}
You can use regexp to match numerical entries in your cell. The expression below matches numbers from 0-9 for 6 times since the numbers in your cell have exactly 6 digits.
x={'100614,Peter Beadle,131542'};
[tokens,matches] = regexp(x,'[0-9]{6}','match');
x = str2double(tokens{:});
For input:
x = {'100614','Peter Beadle','131542'}
Use the following:
x = {'100614','Peter Beadle','131542'};
x = str2double(x);
x(isnan(x)) = [];
10 件のコメント
Paolo
2018 年 6 月 10 日
You are welcome. In that case, try using:
x = [8213430049,100573,100614];
x = num2str(x);
x = strsplit(x,' ');
x = str2double(strcat(x{1}(1),'.',x{1}(2:end),x{2}));
x = 8.213430049100573
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!