Question: Write a function named rowproduct that takes as input two matrices A and B and a random number k , and as output produces the
Write a function named rowproduct that takes as input two matrices A and B and a random number k and as output produces the product, C by rows of the two matrices and the intermediate value, z of the output matrix at the end of k iterations the matrix z is used by MATLAB Grader to determine whether your code is correct
The function should work for any dimension of A and B and it should perform a check to see if the dimensions match and return an empty product matrix if the dimensions do not match.
Specific instructions for writing the function:
Extract the dimension of A using the command size and store the result in the variables m and n
Extract the dimension of B using the command size and store the result in the variables p and q
Use an if statement to perform a check on the dimensions to determine whether the multiplication is defined
If the multiplication is defined:
initialize C as a matrix of zeros of the appropriate dimension
use a single for loop to evaluate the product C AB The loop counter should be the variable i Each iteration of the for loop should evaluate the ith row of the matrix C as the product of the ith row of the matrix A times the matrix B Also, inside the for loop, after you compute the ith row of C insert the following commands:
if isequalik
z C;
end
If the multiplication is not defined, display the message 'dimensions do not match' and return an empty C vector and an empty z vector.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
