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

19 views (last 30 days)
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]

Accepted Answer

KSSV
KSSV on 6 Oct 2018
new_A=zeros(size(B));
new_A(2:end,2:end)=A;

More Answers (0)

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!