MATLAB: I want to add a 20 by 20 matrix to a 50 by 50 matrix ? the resuting matrix should be of 50 by 50 .

addition of square matrices

For Example : A=5*ones(50) & B=2*ones(20) , how should A+B be evaluated ?

Best Answer

A=5*ones(50)
B=zeros(50);
B(1:20,1:20)=2*ones(20);
C=A+B;