Azzera filtri
Azzera filtri

zero padding in matrix

32 visualizzazioni (ultimi 30 giorni)
Anvinder  Singh
Anvinder Singh il 29 Apr 2016
Commentato: Rohit Kharat il 20 Gen 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 Commento
Roger Stafford
Roger Stafford il 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?

Accedi per commentare.

Risposta accettata

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

Più risposte (1)

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

Categorie

Scopri di più su Shifting and Sorting Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by