string split in cell array

6 visualizaciones (últimos 30 días)
Murugan C
Murugan C el 24 de Abr. de 2020
Editada: Tommy el 24 de Abr. de 2020
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 comentarios
Tommy
Tommy el 24 de Abr. de 2020
Happily, though seems to me you did all the work!
dpb
dpb el 24 de Abr. de 2020
You had the bright (and to me right) idea, though...the rest is a oneliner...

Iniciar sesión para comentar.

Respuesta aceptada

Tommy
Tommy el 24 de Abr. de 2020
Editada: Tommy el 24 de Abr. de 2020
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'}

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by