Adding a frame of zeros to a matrix
4 ビュー (過去 30 日間)
古いコメントを表示
I have a matrix 19x9 I want to add a frame of zeros so I will be 20x10 ?????
0 件のコメント
採用された回答
Guillaume
2019 年 4 月 4 日
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 件のコメント
Guillaume
2019 年 4 月 4 日
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]);
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Image Processing Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!