I have to write a Matlab script that does this:
The input is 2 matrices, A(m x n) and D(m x 1). The output is a matrix, C (m x n). C is calculated like this:
function c = scanrow(a,d)
[rows columns] = size(d);
for i=1:columns
a(i,:) = a(i,:).*d(i);
end
c = a;
end
The requirement is not using recursion. I have no idea to solve this problem. Glad that you can help.
Thank you.
If the problem is “multiply every element in each row of A with the corresponding element on the corresponding row of D” then I would suggest the following:
Example: