Putting 1 around the matrix
2 次查看(过去 30 天)
显示 更早的评论
Hi I have a 3X3 matrix and want to put 1 around the matrix as it will become 4X4 matrix.....
采纳的回答
Andrei Bobrov
2016-9-23
Let A - your matrix [3 x 3]:
A = magic(3);
out = ones(2 + size(A));
out(2:end-1,2:end-1) = A;
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multidimensional Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!