フィルターのクリア

Add lines and rows around an array

5 ビュー (過去 30 日間)
Alan Meier
Alan Meier 2020 年 4 月 6 日
コメント済み: darova 2020 年 4 月 6 日
Is there a simple way to add single lines and rows around an existing array, like a boundary box.
E.g.:
1 2 3 4
4 5 6 7
7 8 9 0
shoud go to:
11 11 11 11 11 11
11 1 2 3 4 11
11 4 5 6 7 11
11 7 8 9 0 11
11 11 11 11 11 11
I know that I can insert a line and row at position one, e.g. like here, and append a line and row at the end like here, but maybe there is a more efficient solution?

採用された回答

Alan Meier
Alan Meier 2020 年 4 月 6 日
c = rand(3,3) %an example
a = zeros(3+2,3+2)+11;
a(2:4,2:4)= c
  1 件のコメント
darova
darova 2020 年 4 月 6 日
It works

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by