How to add zeros column and row at the beginning of matrix

21 ビュー (過去 30 日間)
NA
NA 2018 年 10 月 6 日
編集済み: Stephen23 2018 年 10 月 6 日
I have A and B
A=[1,3,5;4,6,8;9,7,4]
B=[1,2,4,6;7,1,2,4;6,7,8,9;4,5,6,7]
if size(B)> size(A) Add zeros column and row at the beginning of matrix A
New_A=[0,0,0,0;0,1,3,5;0,4,6,8;0,9,7,4]

採用された回答

KSSV
KSSV 2018 年 10 月 6 日
new_A=zeros(size(B));
new_A(2:end,2:end)=A;

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by