creating a large matrix with a pattern
    18 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    bus14
 el 16 de Mayo de 2019
  
    
    
    
    
    Editada: Andrei Bobrov
      
      
 el 16 de Mayo de 2019
            Hi,
I would like to create a 800x200 matrix which looks like: 
     1     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
     1     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
     1     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
     0     1     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
     0     1     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
     0     1     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
     0     0     1     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
To put in in words, every new column should start with the column [1 1 0 1].' when the other is finished. 
Tried to do this with toeplitz. However this results in only 1 step change of columns e.g.
     1     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
     1     1     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
     0     1     1     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
     1     0     1     1     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
     0     1     0     1     1     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
     0     0     1     0     1     1     0     0     0     0     0     0     0     0     0     0     0     0     0     0
     0     0     0     1     0     1     1     0     0     0     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     1     0     1     1     0     0     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     1     0     1     1     0     0     0     0     0     0     0     0     0     0     0
 This is not what I desire. Does anyone know another way to do this?
0 comentarios
Respuesta aceptada
  convert_to_metric
      
 el 16 de Mayo de 2019
        
      Editada: convert_to_metric
      
 el 16 de Mayo de 2019
  
      Hi bus14,
Try this:
m=zeros(804,200);
m([1,2,4],:)=1;
m2=reshape(m,800,[]);
m2(:,201)=[];
0 comentarios
Más respuestas (1)
  Andrei Bobrov
      
      
 el 16 de Mayo de 2019
        
      Editada: Andrei Bobrov
      
      
 el 16 de Mayo de 2019
  
      out = kron(eye(200),[1;1;0;1]);
or
a = [1;1;0;1;zeros(796,1)];
out = a(mod((1:800)'-(1:4:800),800)+1);
0 comentarios
Ver también
Categorías
				Más información sobre Resizing and Reshaping 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!


