how can I add zeros elements to a matrix?
Mostrar comentarios más antiguos
I have a matrix a: a= [1 2 3; 1 2 3; 1 2 3] I want to add zero rows and cols and convert it to b:
b=
1 2 3 0 0
1 2 3 0 0
1 2 3 0 0
0 0 0 0 0
0 0 0 0 0
how is it possible?
(size of 'a' can be different, in fact it's a matrix which shows image m*n)
Respuesta aceptada
Más respuestas (2)
Andrei Bobrov
el 18 de Jun. de 2015
a= [1 2 3; 1 2 3; 1 2 3]
b = a
b(5,5) = 0
Ugur Aygun
el 26 de Oct. de 2016
Hi Moein,
Easiest way to do this is to use padarray command.
a= [1 2 3; 1 2 3; 1 2 3];
padarray(a,[2,2],0,'post')
ans =
1 2 3 0 0
1 2 3 0 0
1 2 3 0 0
0 0 0 0 0
0 0 0 0 0
Here [2,2] indicates how many terms you will add to rows and columns respectively.
1 comentario
David Buzzell
el 28 de Sept. de 2020
This requires the Image Processing Toolbox
Categorías
Más información sobre BeagleBone Black en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!