How to Multiplying matrices using for loops

14 vues (au cours des 30 derniers jours)
Mark  Hodges
Mark Hodges le 16 Sep 2016
Commenté : Walter Roberson le 16 Sep 2016
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!

Réponses (1)

Walter Roberson
Walter Roberson le 16 Sep 2016
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 commentaires
Mark  Hodges
Mark Hodges le 16 Sep 2016
My apologies, I didn't mean to add that, it's fixed
Walter Roberson
Walter Roberson le 16 Sep 2016
https://en.wikipedia.org/wiki/Matrix_multiplication#General_definition_of_the_matrix_product

Connectez-vous pour commenter.

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by