how to pad the matrix with ones?

3 ビュー (過去 30 日間)
Muhammad
Muhammad 2021 年 8 月 21 日
回答済み: Walter Roberson 2021 年 8 月 21 日
i want to padded the input matixe of any row and colum with one
for eaxmple if i take input matrix A
A = 1 2 3
4 5 6
7 8 9
then padden one should be
A = 1 1 1 1 1
1 1 2 3 1
1 4 5 6 1
1 7 8 9 1
1 1 1 1 1
for it is there is any command or if not then what will be the code

採用された回答

Walter Roberson
Walter Roberson 2021 年 8 月 21 日
A = [1 2 3
4 5 6
7 8 9]
A = 3×3
1 2 3 4 5 6 7 8 9
B = padarray(A, [1 1], 1)
B = 5×5
1 1 1 1 1 1 1 2 3 1 1 4 5 6 1 1 7 8 9 1 1 1 1 1 1

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAssembly についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by