i need to pad my matrix only from the ends like this picture

조회 수: 1 (최근 30일)
Afnan
Afnan 2022년 11월 19일
댓글: Bruno Luong 2022년 11월 19일

답변 (1개)

DGM
DGM 2022년 11월 19일
편집: DGM 2022년 11월 19일
You should be able to use padarray() to pad with constant values.
A = magic(5)
A = 5×5
17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9
Apadded = padarray(A,[3 3],0,'post')
Apadded = 8×8
17 24 1 8 15 0 0 0 23 5 7 14 16 0 0 0 4 6 13 20 22 0 0 0 10 12 19 21 3 0 0 0 11 18 25 2 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
In this example, [3 3] specifies the pad width in each dimension. The pad value is 0, and 'post' specifies that only the trailing edge gets padded in either dimension.

카테고리

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

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by