필터 지우기
필터 지우기

Pad array to certain size

조회 수: 27 (최근 30일)
raheem mian
raheem mian 2020년 2월 11일
댓글: TJ 2020년 10월 30일
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
James Tursa
James Tursa 2020년 2월 11일
What about the 3rd dimension? How is your overall padding supposed to work?
raheem mian
raheem mian 2020년 2월 11일
X is a 200x200 matrix with random integer values up to 256.

댓글을 달려면 로그인하십시오.

답변 (1개)

SaiDileep Kola
SaiDileep Kola 2020년 2월 11일
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
TJ
TJ 2020년 10월 30일
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?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by