could to create the categorical values for 2x2 cell array
    4 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
I having cell array of 15x1. A (input training data for clustering)=15×1 cell array
    {2×1 double}
    {2×1 double}
    {2×1 double}
    {2×1 double}
    {2×1 double}
    {2×2 double}
    {2×2 double}
    {2×2 double}
    {2×2 double}
    {2×2 double}
    {2×3 double}
    {2×3 double}
    {2×3 double}
    {2×3 double}
    {2×3 double}
B(targets for clustering) needs to be in the following manner.
     [  1	
        1	
        1	
        1	
        1	
        1	1	
        1	2	
        2	1	
        2	1	
        1	2	
        1	2	2
        2	1	1
        1	3	2
        1	1	2
        2	2	1]
Could you please help me to get it.
1 comentario
Respuestas (1)
  Walter Roberson
      
      
 el 23 de Jun. de 2021
        B = cellfun(@convert_to_categorical, A, 'uniform', 0);
function C = convert_to_categorical(M)
   if iscell(M)
      C = cellfun(@convert_to_categorical, M, 'uniform', 0);
   else
      C = categorical(M);
   end
end
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


