zero padding in matrix

37 次查看(过去 30 天)
Hi, I have a 5x5 matrix and i would like to pad it with zeros such that its size becomes 200x200 and the 5x5 matrix is in the middle of the 200x200. Please help.
  1 个评论
Roger Stafford
Roger Stafford 2016-4-29
You can't precisely center a 5x5 block in a 200x200 block! In which direction do you want it to be off-center?

请先登录,再进行评论。

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2016-4-29
a=magic(5) % example
b=zeros(200)
b(98:102,98:102)=a

更多回答(1 个)

Anvinder  Singh
Anvinder Singh 2016-4-29
Just struck my brain ! Thanks Azzi Abdelmalek for the quick response.

类别

Help CenterFile Exchange 中查找有关 Operating on Diagonal Matrices 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by