How to Multiplying matrices using for loops
14 ビュー (過去 30 日間)
古いコメントを表示
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!
0 件のコメント
回答 (1 件)
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 件のコメント
Walter Roberson
2016 年 9 月 16 日
https://en.wikipedia.org/wiki/Matrix_multiplication#General_definition_of_the_matrix_product
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!