How do I pad with zeros?

조회 수: 2 (최근 30일)
Ryan
Ryan 2021년 5월 18일
편집: Cris LaPierre 2021년 5월 18일
Rather than extracting the last row from the top and bottom of X_proj_corrected, I want to add 100 rows of zeros to either the top or bottom of X_proj_corrected using padarray function?
%Extract last row from X_proj_corrected sinogram from top and bottom
X_proj_corrected_padded100 = [X_proj_corrected(1,:); X_proj_corrected];
X_proj_corrected_padded100 = [X_proj_corrected; X_proj_corrected (size(X_proj_corrected,1),:)];
%Using last row from top and bottom 100 rows padded top and bottom using IPT
X_proj_corrected_padded100 = padarray(X_proj_corrected,100,'replicate','both');
figure
imagesc(X_proj_corrected_padded100)
  댓글 수: 2
David Hill
David Hill 2021년 5월 18일
Hard to understand your description. Please provide a simple example of what you want to do. It should be quite easy.
Ryan
Ryan 2021년 5월 18일
Hi David, rather than extracting the last row from the top and bottom of X_proj_corrected, I want to add 100 rows of zeros to either the top or bottom of X_proj_corrected using padarray function? Thanks.

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

채택된 답변

Cris LaPierre
Cris LaPierre 2021년 5월 18일
편집: Cris LaPierre 2021년 5월 18일
To pad with 100 rows of zeros, do the following
% to add to the top
X_proj_corrected = padarray(X_proj_corrected,100,'pre');
% to add to the bottom
X_proj_corrected = padarray(X_proj_corrected,100,'post');
  댓글 수: 1
Ryan
Ryan 2021년 5월 18일
Great! Thanks Cris, now working as expected.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by