How to concatenate the elements of the structure?
    9 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    M
 el 22 de Nov. de 2023
  
    
    
    
    
    Comentada: Stephen23
      
      
 el 22 de Nov. de 2023
            If there is a structure with size 1*12, each element is 3D with size 120*12*N , How can I  concatenate the elements of this structure?
0 comentarios
Respuesta aceptada
  Stephen23
      
      
 el 22 de Nov. de 2023
        Where S is your structure and F is the relevant field:
cat(3,S.F)
2 comentarios
  Stephen23
      
      
 el 22 de Nov. de 2023
				"What about   concatenation the elements of cell array 1*12 not structured  with elements with size 120*12*N? "
Then use the cell array syntax shown in the tutorial. For example:
C = {rand(120,12,3), rand(120,12,5), rand(120,12,2), rand(120,12,1), rand(120,12,0), rand(120,12,4)};
A = cat(3,C{:});
size(A)
"I tried cat but it gave me error   Dimensions of arrays being concatenated are not consistent."
Then the dimensions of one or more of the arrays are not what you explained in your question.
Lets try it right now:
S = struct('F',C)
A = cat(3,S.F);
size(A)
Más respuestas (0)
Ver también
Categorías
				Más información sobre Matrices and Arrays 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!

