Split the given string into characters
古いコメントを表示
I have a column in my table that has values such as '2.6ELKUxQKWPVJVHxxxxC.4xxxIxSxJJxxxxx', it has altogether 37 single characters. I want to split the string into 37 different columns for further data analysis. I have tried using 'split' function, but it doesn't work.
1 件のコメント
"I want to split the string into 37 different columns..."
Your char vector already has 37 columns. This is easy to check:
>> str = '2.6ELKUxQKWPVJVHxxxxC.4xxxIxSxJJxxxxx';
>> size(str)
ans =
1 37
採用された回答
その他の回答 (2 件)
KSSV
2018 年 5 月 17 日
str = '2.6ELKUxQKWPVJVHxxxxC.4xxxIxSxJJxxxxx' ;
iwant = cell(1,length(str)) ;
for i = 1:length(str)
iwant{i} = str(i) ;
end
3 件のコメント
Much simpler to use num2cell:
iwant = num2cell(str);
Guillaume
2018 年 5 月 17 日
And even much simpler is not to bother at all. str already has 37 different columns. Each one can be accessed with str(columnindex).
Guillaume
2018 年 5 月 17 日
A char array such as
str = '2.6ELKUxQKWPVJVHxxxxC.4xxxIxSxJJxxxxx'
already has different columns. If you want to access column 6 of str, it's simply:
str(6)
Exactly the same as when accessing columns of a numerical matrix.
1 件のコメント
Image Analyst
2018 年 5 月 17 日
He means columns of his table, not columns of that string.
カテゴリ
ヘルプ センター および File Exchange で Data Type Identification についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!