string split in cell array

7 次查看(过去 30 天)
Murugan C
Murugan C 2020-4-24
编辑: Tommy 2020-4-24
Hi Guys!
I am trying to split a numberic sting in cell array data. but unable to do it.
a = {'c\datat\pic\res\000-774'; '\c\datat\pic\res\152-7987';}
need output like
a1 = ('c\datat\pic\res\';'c\datat\pic\res\ ')
a2 = ('000-774';'125-7957')
can anyone help me to solve.
thanks in adavance!!
  5 个评论
Tommy
Tommy 2020-4-24
Happily, though seems to me you did all the work!
dpb
dpb 2020-4-24
You had the bright (and to me right) idea, though...the rest is a oneliner...

请先登录,再进行评论。

采纳的回答

Tommy
Tommy 2020-4-24
编辑:Tommy 2020-4-24
Use fileparts and cellfun. Code courtesy of @dpb:
>> a = {'c\datat\pic\res\000-774'; '\c\datat\pic\res\152-7987'};
[a1,a2]=cellfun(@fileparts,a,'UniformOutput',false)
a1 =
2×1 cell array
{'c\datat\pic\res' }
{'\c\datat\pic\res'}
a2 =
2×1 cell array
{'000-774' }
{'152-7987'}

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by