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!