How to split a table column into two seperate columns
    36 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Cem Akinci
 el 2 de Mayo de 2022
  
    
    
    
    
    Comentada: Star Strider
      
      
 el 2 de Mayo de 2022
            I have a table which looks like this:

I want to split column a into two seperate columns from the delimiter "\" such that first column will be like 'AIVA-100' and the other column will be '01_Test.....'.
I want to do this for every element in column a. In the end, i will have 2 columns with the elements of column a.
I tried to iterate through the table and split using the delimiter but i couldn't do it
0 comentarios
Respuesta aceptada
  Star Strider
      
      
 el 2 de Mayo de 2022
        C = {'AIVA-100\something'; 'AIVA-75\something else'};
Cs = regexp(C,'\','split')
Cs{1}
Cs{2}
Cs = cellfun(@(x)split(x,'\'), C, 'Unif',0)                     % The 'split' Function Requires 'cellfun'
Cs{1}
Cs{2}
.
4 comentarios
Más respuestas (2)
  Dyuman Joshi
      
      
 el 2 de Mayo de 2022
        y = {'AIVA_1\abc';'AIVA_12\def';'AIVA_123\xyz'}
z=split(y,'\')
column1 = z(:,1)
column2 = z(:,2)
  Matt Butts
      
 el 2 de Mayo de 2022
        Not super elegant, but you could use something like:
t = table() % your table
% Split by tokens to grab the first part of a and put it back into a, put
% the remainder in new_a
[t{:,'a'},t{:,'new_a'}] = strtok(t{:,'a'},'\');
% Get rid of the leading delimiter in new_a and put the results back into
% new_a
t{;,'new_a'} = strtok(t{:,'new_a'},'\');
0 comentarios
Ver también
Categorías
				Más información sobre Variables en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





