How to split a column in a table into two columns?
조회 수: 8 (최근 30일)
이전 댓글 표시
Hi,
I have a table that has column like this:
name_num
ABC_123
EFG_456
GGGG
HHHHH
I would like to split the column into two: name and num like this:
name num
ABC 123
EFG 456
GGGG N/A
HHHHH N/A
I thought of varfun but I have difficulty with it. Would anyone help me?
Thank you.
Jennifer
댓글 수: 0
채택된 답변
Azzi Abdelmalek
2015년 8월 24일
편집: Azzi Abdelmalek
2015년 8월 24일
name_num={'ABC_123','EFG_456','GGGG','HHHHH'}
s1=regexp(name_num,'[^\d_]+','match')
s2=regexp(name_num,'\d+','match')
s2(cellfun(@isempty,s2))={'N/A'}
out=[[s1{:}]' [s2{:}]']
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!