Filter löschen
Filter löschen

zero padding in matrix

32 Ansichten (letzte 30 Tage)
Anvinder  Singh
Anvinder Singh am 29 Apr. 2016
Kommentiert: Rohit Kharat am 20 Jan. 2022
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 Kommentar
Roger Stafford
Roger Stafford am 29 Apr. 2016
You can't precisely center a 5x5 block in a 200x200 block! In which direction do you want it to be off-center?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 29 Apr. 2016
a=magic(5) % example
b=zeros(200)
b(98:102,98:102)=a
  1 Kommentar
Rohit Kharat
Rohit Kharat am 20 Jan. 2022
Any generalization to above?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

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

Kategorien

Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by