MATLAB Answers

Pad array to certain size

53 views (last 30 days)
raheem mian
raheem mian on 11 Feb 2020
Answered: SaiDileep Kola on 11 Feb 2020
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 Comments

James Tursa
James Tursa on 11 Feb 2020
What about the 3rd dimension? How is your overall padding supposed to work?
raheem mian
raheem mian on 11 Feb 2020
X is a 200x200 matrix with random integer values up to 256.

Sign in to comment.

Answers (1)

SaiDileep Kola
SaiDileep Kola on 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

  0 Comments

Sign in to comment.

Categories


Translated by