Hello I am relatively new to the matlab program and am struggling with this assignment.
Recall that if A is an m n matrix and B is a p q matrix, then the product C = AB is defined if and only if n = p, in which case C is an m q matrix. (a) Write a function M-file that takes as input two matrices A and B, and as output produces the product by rows of the two matrices. For instance, if A is 3 4 and B is 4 5, the product AB is given by the matrix C = [A(1,:)*B; A(2,:)*B; A(3,:)*B] The function file should work for any dimension of A and B and it should perform a check to see if the dimensions match (Hint: use a for loop to define the rows of C).
I have been able to clear my function of errors so that it returns an answer, however its not coming back as a matrix of the correct dimensions. I get the answer returned row by row it appears. My function is written as follows:
I have typed the following elements into matrices A and B in the command window with the ans following.
I expected a 2×2 matrix with elements [14,14;42,42].
Thanks for the help!
Best Answer