I am just a beginner using MatLab. I wanted to add 2 matrices in which user inputs dimension of matrix and then inputs values.
Values are inserted element by element. I want user to input values row-wise, i.e., for a 2x3 matrix, user should input 2 lines, each line with 3 space separated integer values.
m = input('Enter no. of rows ');
n = input('Enter no. of columns ');
A = zeros(m, n);
B = zeros(m, n);
C = zeros(m, n);
disp('Enter elements in matrix A ');
for i=1 : m
for j=1 : n
A(i,j) = input('\');
end
end
disp('Enter elements in matrix B ');
for i = 1 : m
for j = 1 : n
B(i, j) = input('\');
C(i, j) = A(i, j) + B(i, j);
end
end
clc;
disp('Matrix A is');
A
disp('Matrix B is');
B
disp('Matrix A + B is');
C
How shall i do that?