MATLAB help needed Question 48 is the problem Write your own code to perform mat
ID: 3820808 • Letter: M
Question
MATLAB help needed
Question 48 is the problem
Write your own code to perform matrix multiplication. Do not use any vectorizing -- use nested for loops. Details are provided in the problem statement in the text.
function [C]=mymatmult(A,B)
% mymatmult - multiplies two matrices, with looping
Explanation / Answer
%This script demonstrates matrix multiplication
A=[3 8 0; 1 2 5];
B=[1 3 2 4; 4 5 1 2; 0 2 3 4];
[m n]=size(A);
[nb p]=size(B);
If n~=nb
disp(‘Cannot perform this matrix multiplication’)
else
C=zeros(m,p);
for i=l:m
for j=l:p
mysum=0;
for k=l:n
mysum=mysum + A(i.k) * B(k,j);
end
C(i , j)= mysum;
end
end
C
end
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.