I am taking inputs from user to enter row n column and adding two matrix. But the output i am getting is of different dimension. please tell me what is the problem in given code.
m = input('Enter number of rows: '); n = input('Enter number of columns: '); for i = 1:m for j = 1:n str = ['Enter element in row ' num2str(i) ', col ' num2str(j) ': ']; T(i,j) = input(str); end end %a = input('Enter number of rows: ');
%b = input('Enter number of columns: ');
strn = ['Enter elements for matrix S']for i = 1:m for j = 1:n strn = ['Enter element in row ' num2str(i) ', col ' num2str(j) ': ']; S(i,j) = input(strn); end end string= ['Addition is:']for i=1:m for j=1:n C(i,j)=0; endendC(i,j)=0for i= 1:m for j=1:n C(i,j)= T(i,j)+ S(i,j) endend
Best Answer