Effacer les filtres
Effacer les filtres

zero padding in matrix

33 vues (au cours des 30 derniers jours)
Anvinder  Singh
Anvinder Singh le 29 Avr 2016
Commenté : Rohit Kharat le 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 commentaire
Roger Stafford
Roger Stafford le 29 Avr 2016
You can't precisely center a 5x5 block in a 200x200 block! In which direction do you want it to be off-center?

Connectez-vous pour commenter.

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (1)

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

Catégories

En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by