Increase matrix size, with the first matrix a the center of the new matrix
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
suppose to have a matrix (2000x2000) now i want to copy it in a bigger matrix (4000x4000 for example), with the original matrix at the center of the second matrix, and the other values set to 0. How can I do?
I have done it with for loop, but it is slow
0 comentarios
Respuestas (1)
Turlough Hughes
el 12 de Oct. de 2020
Editada: Turlough Hughes
el 12 de Oct. de 2020
There is a function made specifically for this called padarray, try the following example:
A = rand(2000);
B = padarray(A,[1000 1000]);
2 comentarios
Turlough Hughes
el 12 de Oct. de 2020
Creating an array B=zeros(4000) is unnecessary because you are not using it in the next step. You can simply write:
C = padarray(A,[1000 1000]);
to get what you are looking for.
Ver también
Categorías
Más información sobre Filter Banks 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!