Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

EL 4935-014 Computer Tools Exam 1. 3. Create an m-function that will perform Mat

ID: 2249162 • Letter: E

Question

EL 4935-014 Computer Tools Exam 1. 3. Create an m-function that will perform Matrix addition and Matrix Multiplication Here are the required conditions. (1) Use 4 numbers as arguments. First and second numbers will become row and column number of the first Matrix. The third and fourth numbers will become row and column numbers of the second Matrix. (2) If the dimension of the first Matrix is not equal to the dimension of the second Matrix, the computer WILLNOT perform the addition. (3)ALSO If the column number of the first Matrix is not equal to the row number of the second Matrix, the computer WILLNOT perform the multiplication. to type in individual entries of the two Matrices. Just in case you have forgotten: (4)Once the dimension conditions are cleared, the user should be prompted & AND A Possible Suggestion. Ne do not have any Dimenaion Probiem! He cannot perform the computation. Check the Dimensions The SUM and PRODUCT ARE Not-a-Number! help NaN on MATLAB for Details Nan! SUM Enter row 1 and column 1 Entry of Natrix A Enter row 1 and column 2 Entry ot atrix Enter row 2 and column 1 Entry of Matrix Enter row 2 and column 2 Entry of Matrix a Enter row 1 and column 1 Entry of Matrix B Enter zow 1 and column 2 Entry of Matrix B Enter row 2 and column 1 Entry of MatrixB Enter row 2 and column 2 Entry of Matrix B NaN PRO NaN 7 10 15 22

Explanation / Answer

Please go through the Following Matlab Code:

function [Sum, Product] = sum_pro(r1,c1,r2,c2)

if r1 ~= r2 || c1 ~= c2
display('Computor cannot perform addition (Diamension mismatch)')
if c1 ~= r2
display('Computor cannot perform multiplication (Diamension mismatch)')
end
end
  
if r1 == r2 && c1 == c2 && c1 == r2
display('we donot have a diamension problem enter the value')
display('Data of matrix A')
for i = 1:r1
for j = 1:c1
fprintf('Matrix A row %d column %d',i,j) ;
d = ' value = ';
A(i,j) = input(d);
end
end
matrix_A = A
display('Data of matrix B')
for i = 1:r2
for j = 1:c2
fprintf('Matrix B row %d column %d',i,j) ;
d = ' value = ';
B(i,j) = input(d);
end
end
matrix_B = B
Sum = A + B;
Product = A*B;
end