Respuesta aceptada

Guillaume
Guillaume el 4 de Abr. de 2019
Not sure which corner you want to pad with zeros. I'm assuming bottom right:
newmatrix = [yourmatrix, zeros(size(yourmatrix, 1), 1); zeros(1, size(yourmatrix, 2) + 1)];
If you have the image processing toolbox:
newmatrix = padarray(yourmatrix, [1 1], 'direction', 'post');

2 comentarios

Rashid Hussein
Rashid Hussein el 4 de Abr. de 2019
Actually I want to add the zeros as frame for all corners So the original matrix would be surrendered by zeros like square
newmatrix = [zeros(1, size(yourmatrix, 2) + 2); zeros(size(yourmatrix, 1), 1), yourmatrix, zeros(size(yourmatrix, 1), 1); zeros(1, size(yourmatrix, 2) + 2)];
Using padarray:
newmatrix = padarray(yourmatrix, [1 1]);

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

el 4 de Abr. de 2019

Comentada:

el 4 de Abr. de 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by