clc clear all % exercise 1 - Chapter 27 (nested loops) % add two matrices together disp('Exercise 1 - Chapter 27') disp('Add two matrices') % inputs a=[1 4 6;-7 8 1;0 2 11]; % matrix a b=[0 0 3;12 4 2;5 1 -3]; % matrix b disp('1st matrix:') disp(a) disp('2nd matrix:') disp(b) % code [r,c]=size(a); for i=1:1:r for j=1:1:c add(i,j)=a(i,j)+b(i,j); end end disp('Output matrix:') disp(add)