Putting 1 around the matrix
Ältere Kommentare anzeigen
Hi I have a 3X3 matrix and want to put 1 around the matrix as it will become 4X4 matrix.....
3 Kommentare
Adam
am 23 Sep. 2016
What do you mean by 'around the matrix'? Wouldn't it become 5x5 in that case or do you mean around just one horizontal and one vertical side? If so which sides?
Offroad Jeep
am 23 Sep. 2016
Offroad Jeep
am 23 Sep. 2016
Akzeptierte Antwort
Weitere Antworten (1)
a = zeros(3);
b = padarray( a, [1 1], 1 );
would put 1s all the way round, but this produces a 5x5 matrix. A 4x4 matrix result is ambiguous without being more clearly defined.
Note: This requires the Image Processing Toolbox though
1 Kommentar
Offroad Jeep
am 23 Sep. 2016
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!