Hi,
I have the below cell array and want to split at common dilimiter of the specified column.
Group Sub_group Name Date Value
Group1 S1Gp11 HATU R2016-06-01_00 1
Group1 S1Gp11 HATU R2016-06-01_01 1
Group2 J1Gp21 LARU R2016-06-02_01 0
I want to split at "_" and retain everything before "_".
Desired Output:
Group Sub_group Name Date Value
Group1 S1Gp11 HATU R2016-06-01 1
Group1 S1Gp11 HATU R2016-06-01 1
Group2 J1Gp21 LARU R2016-06-02 0

3 comentarios

Adam Danz
Adam Danz el 27 de Jun. de 2019
It looks like a table, are you sure it's a cell array? Is it a 4x5 cell array?
Mekala balaji
Mekala balaji el 27 de Jun. de 2019
yes, cell array.
Adam Danz
Adam Danz el 27 de Jun. de 2019
Ok, good. See the example in my answer below and feel free to follow-up with any problems or questions.

Iniciar sesión para comentar.

 Respuesta aceptada

Adam Danz
Adam Danz el 27 de Jun. de 2019
Editada: Adam Danz el 1 de Jul. de 2019

1 voto

c = {'Group' 'Sub_group' 'Name' 'Date' 'Value';
'Group1' 'S1Gp11' 'HATU' 'R2016-06-01_00' '1'
'Group1' 'S1Gp11' 'HATU' 'R2016-06-01_01' '1'};
colIdx = strcmpi(c(1,:),'Date'); % column number of "Date" column
cClean = c; %copy the array if you want to keep the original
cClean(:,colIdx) = regexprep(cClean(:,colIdx),'_.*','');
Result
cClean =
3×5 cell array
{'Group' } {'Sub_group'} {'Name'} {'Date' } {'Value'}
{'Group1'} {'S1Gp11' } {'HATU'} {'R2016-06-01'} {'1' }
{'Group1'} {'S1Gp11' } {'HATU'} {'R2016-06-01'} {'1' }

Más respuestas (0)

Categorías

Más información sobre Introduction to Installation and Licensing en Centro de ayuda y File Exchange.

Preguntada:

el 27 de Jun. de 2019

Editada:

el 1 de Jul. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by