if i have 256x256 matrix and i want to zero padding it to 512x512 how can i do ?
4 次查看(过去 30 天)
显示 更早的评论
I have file name k_im which has 256x256 matrix and i want to do zero padding it to matrix 512x512 help me write a code pls tyvm.
0 个评论
回答(2 个)
the cyclist
2019-9-26
编辑:the cyclist
2019-9-26
If not,
paddedM = zeros(512:512);
paddedM(129:384,129:384) = M;
(assuming you want equal padding on all sides, and I did my math right).
0 个评论
James Tursa
2019-9-26
If you just want it padded on two sides, then simply
k_im = your 256x256 matrix
k_im(512,512) = 0; % pad 0's out to (512,512) element
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!