How to combine the matrices that are output by the for loop.
    8 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    Ellie
 il 19 Ago 2015
  
    
    
    
    
    Modificato: Azzi Abdelmalek
      
      
 il 20 Ago 2015
            Hi all,
I am trying to combine all the outputs of a for loop into one large matrix. All the outputs are matrices. Here is my code so far.
s = 1:100; d = reshape(s, [10 10])';
d = mat2cell(d, ones(1,10), 10);
k2 = length(d) * 5;
for k1 = 1:length(d)
   samp1{k1} = randsample(d{k1,1}, k2, true);
   samp2 = reshape(samp1{1,k1},length(d), 5)';
end
Thanks for any help you can give.
Regards.
0 Commenti
Risposta accettata
  Azzi Abdelmalek
      
      
 il 20 Ago 2015
        
      Modificato: Azzi Abdelmalek
      
      
 il 20 Ago 2015
  
      s = 1:100; 
d = reshape(s, [10 10])';
d = mat2cell(d, ones(1,10), 10);
k2 = length(d) * 5;
out=[];
for k1 = 1:length(d)
 samp1{k1} = randsample(d{k1,1}, k2, true);
 samp2 = reshape(samp1{1,k1},length(d), 5)';
 out=[out;samp2];
end
0 Commenti
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

