Pad array to certain size
39 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I would like to pad my matrix x so that the resulting size of the matrix is 425x425.
How would I achieve this ?
x = randi(256,200,200);
2 Kommentare
James Tursa
am 11 Feb. 2020
What about the 3rd dimension? How is your overall padding supposed to work?
Antworten (1)
SaiDileep Kola
am 11 Feb. 2020
Hi Raheem,
This is how you can realize your required outcome,
x=randi(256,200,200); % Initial Matrix
z=zeros(425,425); %New matrix
z(1:200,1:200) = x; % Superimpose x on to appropriate position on z
1 Kommentar
TJ
am 30 Okt. 2020
I am looking for an answer to a similar problem,
I have a 22x1 cell array, where each cell is an n by n matrix (image) mostly around the size 20 x 20 (double values), all of the same image pixel size, 0.04 microns.
I would like to return a 22x1 cell array where each cell is an n by n matrix of equal size, using the solution above this is relatively simple. However, that would displace the real (scaled) location of each matrix. So I would like the all of the original matrices to be at the centre of the returned padded matrices.
Is there a simple solution to this?
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!