MATLAB: Element in matrix multiplication to create a new matrix matrix A and O is 3×1 matrix B and D is 1×3 matrix f is a 3×3 matrix What is wrong with the code below? i=1:3 j=1:3 T(i,j)=A(i).*B(j).*O(i).*D(j).*f(i,j) Best Answer Your code doesn't run because you are using .* which is element wise multiplication instead of standar matrix multiplication. You can do:for i=1:3 for j=1:3 T(i,j)=A(i).*B(j).*O(i).*D(j).*f(i,j) endendorT=A*B*O*D*fdepending on the result you are expecting. Related SolutionsMATLAB: Code for elements in equation to create a matrix Lo, no need to use loops: A = 1./(f*D)Make sure that D is a column vector. MATLAB: Matrix multiplication element wise A.*B.' % ^-—-—-I can see in your code you swapped indices for B(j,i)doc times Related QuestionNested for loops don’t workWhat is the best way to vectorize this matrix problemLooping matrice index at a specific interval, probably with mod
Best Answer