convert a double matrix in cell within a table
    17 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Nikolas Spiliopoulos
 el 11 de Mayo de 2020
  
    
    
    
    
    Respondida: Peng Li
      
 el 11 de Mayo de 2020
            Hi all,
I have a table with size 420x4 (screenshot attached)
However, the first column is a double matrix (420x4) while the rest of the columns are cells
How is possible to convert the double matrix in column 1, in a cell array with each row equal to the matrix row?
I have tried some things but I get an error
thanks in advance! 
0 comentarios
Respuesta aceptada
  Peng Li
      
 el 11 de Mayo de 2020
        t = table([ones(1, 4); ones(1, 4)*2; ones(1, 4)*3])
t =
  3×1 table
          Var1      
    ________________
    1    1    1    1
    2    2    2    2
    3    3    3    3
>> out = varfun(@(x) mat2cell(x, ones(1, size(x, 1)), size(x, 2)), t, 'InputVariables', 'Var1')
out =
  3×1 table
      Fun_Var1  
    ____________
    {1×4 double}
    {1×4 double}
    {1×4 double}
>> out.Fun_Var1{1}
ans =
     1     1     1     1
>> out.Fun_Var1{2}
ans =
     2     2     2     2
>> out.Fun_Var1{3}
ans =
     3     3     3     3
0 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre Tables 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!

