How to Multiplying matrices using for loops

조회 수: 13 (최근 30일)
Mark  Hodges
Mark Hodges 2016년 9월 16일
댓글: Walter Roberson 2016년 9월 16일
I have to write a MATLAB code using for-loops to perform multiplication of both matrices. Not sure how to do this using for loops but A = [3 4 1; 1 2 3] B = [1 2 3; 4 5 6; 7 8 9] Need to Find A*B
Thanks everyone!

답변 (1개)

Walter Roberson
Walter Roberson 2016년 9월 16일
A.*B is not defined between matrices of difference sizes. It is not possible to write code for it.
The .* (otherwise known as times) operator is for element-by-element multiplication. If you are looking for algebraic matrix multiplication then the operator to read about is * (otherwise known as mtimes)
  댓글 수: 2
Mark  Hodges
Mark Hodges 2016년 9월 16일
My apologies, I didn't mean to add that, it's fixed
Walter Roberson
Walter Roberson 2016년 9월 16일
https://en.wikipedia.org/wiki/Matrix_multiplication#General_definition_of_the_matrix_product

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by