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

Really if you could help me with this i will be very thankful, i have a lot of p

ID: 2902671 • Letter: R

Question

Really if you could help me with this i will be very thankful, i have a lot of problems programming

Write a program in Matlab that makes a Matrix Sum, Matrix Substraction, and multiplication of matrix:

The program shall:

Write name and student number.
Briefly describe the program that it serves.
Request data (input arrays).
Ask the operation to perform and ensure that it can perform this operation (if not possible to request new data).
Perform the requested operation on the basis of cycles for (finding each element of the result array, not the operation using matrix operations directly MatLab).

Explanation / Answer

disp('your name here');
disp('your roll number here'); %%% please write here your roll no.

A= input(' Please enter the first matrix ');
B= input('please enter the second matrix ');
n= input(' please enter 1 for addition, 2 for subtraction and 3 for multiplication ');
if n==1

p=size(A);
q= size(B);
if (p(1)==q(1)&& p(2)==q(2))
i=1;

while i<(p(1)+1)
j=1;
while j<(p(2)+1)
C(i,j)= A(i,j)+B(i,j);
j=j+1;
end
i=i+1;
end
C
else
disp(' Matrix size must be same for this operation');
  
end
  
end
if n==2

p=size(A);
q= size(B);
if (p(1)==q(1)&& p(2)==q(2))
i=1;

while i<(p(1)+1)
j=1;
while j<(p(2)+1)
C(i,j)= A(i,j)-B(i,j);
j=j+1;
end
i=i+1;
end
C
else
disp(' Matrix size must be same for this operation');
  
end
  
  
end
if n==3
[nRow1,nCol1]=size(A);
[nRow2,nCol2]=size(B);

if nCol1 ~= nRow2
error(' inner dimensions must match');
end

C = zeros(nRow1,nCol2);

for i = 1:nRow1
for j = 1:nCol2
for k = 1:nCol1
C(i,j) = C(i,j) + A(i,k)*B(k,j);
end
end
end
C
end