Interleaved repmat (row duplication)
    14 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Albert
 el 5 de Nov. de 2021
  
    
    
    
    
    Comentada: Albert
 el 5 de Nov. de 2021
            I would like to do a specific repmat such that if I have:
a=[1 0 0;0 0 1;1 1 1]
I would like to duplicate each row by a value N, so that in the case N = 2  each row will be duplicated twice:
b=[1 0 0;1 0 0;0 0 1;0 0 1;1 1 1;1 1 1]
 Is there an easy way of doing this interleaved repmat? Thanks
0 comentarios
Respuesta aceptada
  Stephen23
      
      
 el 5 de Nov. de 2021
        The simple and efficient approach is to use REPELEM:
a = [1,0,0;0,0,1;1,1,1]
b = repelem(a,2,1)
1 comentario
Más respuestas (1)
  Sudharsana Iyengar
      
 el 5 de Nov. de 2021
        Try this
A=[1,0,0; 0 0 1; 1 1 1;];
k=1;
for i =1:3
T(k:k+1,:)=repmat(A(i,:),2,1);
k=k+2;
end
T
0 comentarios
Ver también
Categorías
				Más información sobre Creating and Concatenating Matrices 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!


