looping a sequence easiest
    6 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Rasmus
 el 16 de Abr. de 2014
  
    
    
    
    
    Comentada: Mischa Kim
    
      
 el 16 de Abr. de 2014
            hello guys!
which way would be the easiest to make a loop of a sequence 1000 times ?
this is my code
-------------------------------------------------------
x0=[zeros(1,276) ones(1,290)]; x=x0(randperm(566)); b=(0:566); d=[x 0]-[0 x]; l=(b(d==(-1))-b(d==1)) L=max(l) -------------------------------
I need L in a propability assignment. For that I need 1000 different results and put it into a histogram. So I need the sequence to repeat it self 1000 times.
How do you do that?
0 comentarios
Respuesta aceptada
  Mischa Kim
    
      
 el 16 de Abr. de 2014
        
      Editada: Mischa Kim
    
      
 el 16 de Abr. de 2014
  
      Something like
 x0 = [zeros(1,276) ones(1,290)];
 L  =  zeros(1,1000);
 b  = (0:566);
 for ii = 1:1000
    x = x0(randperm(566));
    d = [x 0] - [0 x];
    l = (b(d==(-1)) - b(d==1));
    L(ii) = max(l);
 end
2 comentarios
Más respuestas (0)
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!

