How to create a structure of matrices within a loop
    5 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Joanna Przeworska
 el 2 de Mzo. de 2021
  
    
    
    
    
    Comentada: Joanna Przeworska
 el 3 de Mzo. de 2021
            Dear all,
Using the following code, I would like to create a structure containing 3 matrices that are the result of a loop. I want these matrices to be named within this structure, e.g. 'A', 'B' and 'C'. What should I improve in my code?
for s0 = 1:3
    matrixOfCodes = cell(size(matrixOfNames,2), length(codePart1));
    for s1 = 1:size(matrixOfNames,2)
        for s2 = 1:length(codePart1)
            fullPath = strcat(codePart1{s2}, matrixOfNames{s0,s1}, codePart2{s2});
            matrixOfCodes{s1, s2} = fullPath;
        end
    end
m{s0} = matrixOfCodes;
matrixOfCodes = [];
end
0 comentarios
Respuesta aceptada
Más respuestas (1)
  Joanna Przeworska
 el 2 de Mzo. de 2021
        2 comentarios
  Stephen23
      
      
 el 2 de Mzo. de 2021
				@Joanna Przeworska: I fixed my answer. You will need this:
m.(database{s0}) = ..
%          ^^^^ index
Ver también
Categorías
				Más información sobre Loops and Conditional Statements 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!

