MATLAB: Function takes as input two nonempty matrices A and B and returns the product AB

homeworkmatrix multiplication

My task is to write a MATLAB function that takes as input two nonempty matrices A and B and returns the product AB where the number of columns in A is the same as the number of rows in B. I have a small program written so far, however it is not fully developed. I am asking for assistance on where to go next with developing a program that is accurate. I apologize that there is not much in my program so far. Here is what I have so far:
function AB = ex2(A,B)
%
%
[NRows,NCols] = size(A);
[NRows,NCols] = size(B);
AB = zeros('NRows of A, NCols') % I am not sure what to put here
for row = 1:NRows
for col = 1:NCols
AB = A(row,col) * B(row,col);
end
end

Best Answer

function AB = ex2(A,B)
%

%
% we need rows and columns of both A and B
% ColsA should be equal to RowsB
[RowsA,ColsA] = size(A);
[RowsB,ColsB] = size(B);
AB = zeros(RowsA, ColsB);
for row = 1:RowsA
for col = 1:ColsB
AB(row,col) = sum(A(row,:)'.*B(:,col));
end
end