adding a padding to matrix.
    4 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
for example, i have a vector A = [ which has 43 elements ]
if i use reshape (A,9,5)
there is an error since i lack 2 elements to make a 5x9 table. how do i add empty elements to the matrix?
Respuestas (1)
  Matt J
      
      
 el 30 de Sept. de 2012
        
      Editada: Matt J
      
      
 el 30 de Sept. de 2012
  
      You haven't specified where the padding should go (beginning/end) and with what values, but this should give you the idea:
A(45)=0; %pad the vector with zeros
B=reshape (A,9,5)
2 comentarios
  Matt J
      
      
 el 30 de Sept. de 2012
				With cell arrays, you can do something like that,
 A=num2cell(A);
 A{45}=[]; %pad with empty
 B=reshape(A,9,5);
As for "padding in random places", you can do things like this:
 A=num2cell(A);
 B=cell(9,5);
 B(1:20)=A(1:20);
 B(23:end)=A(21:end);
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!

