pad matrix to a particular size
Mostra commenti meno recenti
I have a matrix M of size m x n
m and n may or may not be equal - M can be rectangular or square matrix - where m and n are less than 150,
I wanted to resize M to 150 x 150 by padding border with zeros, such that the m x n will come in the center
M_resized = padarray(M,[x y],0,'both');
how to compute value for x and y such that i can use the same line of code for any matrix,
or is there any another way to do?
Risposta accettata
Più risposte (1)
David Hill
il 13 Mag 2021
assuming m and n are both even.
M_resized=padarray(M,[(150-size(M,1))/2 (150-size(M,2))/2],0,'both');
1 Commento
Elysi Cochin
il 13 Mag 2021
Modificato: Elysi Cochin
il 13 Mag 2021
Categorie
Scopri di più su Neuroimaging in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!