making blocks using for loop
    4 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Raza
 el 17 de Feb. de 2014
  
    
    
    
    
    Comentada: Raza
 el 19 de Feb. de 2014
            hi, i have number of bits (1 ans 0) and i want to have these bits in a block of 10 bits. let for example s=101010001110100101010010010001010 i want to put first 10 bits in b1 next ten bits in b2, next ten bits in b3 and the remaining bit in b4 with padding bits(to complete 10 bits in b4)
0 comentarios
Respuesta aceptada
  Mischa Kim
    
      
 el 17 de Feb. de 2014
        
      Editada: Mischa Kim
    
      
 el 17 de Feb. de 2014
  
      Raza, this should do the trick:
s  = '101010001110100101010010010001010'
s0 = '000000000';
b = {};
for ii = 1:floor(length(s)/10)
    ind   = 10*(ii-1) + 1;
    b{ii} = s(ind:ind + 9);
end
b{ii+1} = strcat(s(10*ii + 1:end),s0(1:10*(ii+1) - length(s)));
disp(b)
Más respuestas (0)
Ver también
Categorías
				Más información sobre Logical 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!

