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

For matrices A and B, if the values of the individual cells match, place that va

ID: 3564020 • Letter: F

Question

For matrices A and B, if the values of the individual cells match, place that value into a new matrix C. If the values do not match then place a 0. Use a nested for-loop with conditional statements to construct the resulting matrix C.

A =    9.00          4.00          2.00

          7.00          5.00          3.00

          6.00          8.00          9.00


B =    5.00          4.00          3.00

          7.00          6.00          8.00

          9.00          2.00          9.00

Matrix C should look like this:

C =       0          4.00             0

          7.00             0             0

             0             0          9.00

Explanation / Answer

**NOTE: You may change the matrices A and B by replacing its elements in the code.

**The main program to calculate the resulting matrix C will remain same.

**The program is tested in MATLAB and u may verify.

**PLEASE RATE !!!

MATLAB Code

clc;clear all;close all;
A=[9,4,2;7,5,3;6,8,9];
B=[5,4,3;7,6,8;9,2,9];
for i=1:3
    for j=1:3
        if(A(i,j)==B(i,j))
            C(i,j)=A(i,j);
        else
            C(i,j)=0;
        end;
    end;
end;
disp(' ');A
disp(' ');B
disp(' ');C