Putting 1 around the matrix
1 view (last 30 days)
Show older comments
Offroad Jeep
on 23 Sep 2016
Commented: Offroad Jeep
on 23 Sep 2016
Hi I have a 3X3 matrix and want to put 1 around the matrix as it will become 4X4 matrix.....
3 Comments
Accepted Answer
Andrei Bobrov
on 23 Sep 2016
Let A - your matrix [3 x 3]:
A = magic(3);
out = ones(2 + size(A));
out(2:end-1,2:end-1) = A;
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!