How can i split between strings that connected with under score?
14 次查看(过去 30 天)
显示 更早的评论
" x= 'Penelope_Cruz' 'Gary_Cooper' 'Tony_Curtis' 'Jim_Carrey'"
I want to split x into two different variables, like this:
a= 'Penelope' 'Gary' 'Tony' 'Jim'
b= 'Cruz' 'Cooper' 'Curtis' 'Carrey'
I want to do it for unknown amount of names.
0 个评论
采纳的回答
更多回答(1 个)
Walter Roberson
2015-5-23
T = regexp(x, '_', 'split');
a = cellfun(@(C) C{1}, T);
b = cellfun(@(C) C{2}, T);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!