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

Matrix Multiplication- Old fashioned way 0 solutions submitted (max: Unlimited)

ID: 3709853 • Letter: M

Question

Matrix Multiplication- Old fashioned way 0 solutions submitted (max: Unlimited) In many programming languages, marix multiplication is not available by default and programers need to write their own functions for this operation. This can be acheived by implementing two for loops. Pretend that Matlab does not have matrix mutiplication capability and write a function that takes two confoming matrices as the input and mutiplies the firt one by the xecond one and assigns it to the output Your Function C Reset MATLAB Docu 1 function C MatMultiply (A, B) 3 end

Explanation / Answer

function C = MatMultiply(A, B)
    [r1, c1] = size(A);
    [r2, c2] = size(B);
    C = [];
    for i=1:r1
        for j=1:c2
            s = 0;
            for k=1:c1
                s = s + (A(i, k) * B(k, j));
            end
            C(i, j) = s;
        end
    end
end