- Matlab教程
- MATLAB - 主页
- MATLAB - 概述
- MATLAB - 环境设置
- MATLAB - 语法
- MATLAB - 变量
- MATLAB - 命令
- MATLAB - M 文件
- MATLAB - 数据类型
- MATLAB - 运算符
- MATLAB - 决策
- MATLAB - 循环
- MATLAB - 向量
- MATLAB - 矩阵
- MATLAB - 数组
- MATLAB - 冒号表示法
- MATLAB - 数字
- MATLAB - 字符串
- MATLAB - 函数
- MATLAB - 数据导入
- MATLAB - 数据输出
- MATLAB 高级版
- MATLAB - 绘图
- MATLAB - 图形
- MATLAB - 代数
- MATLAB - 微积分
- MATLAB - 微分
- MATLAB - 集成
- MATLAB - 多项式
- MATLAB - 变换
- MATLAB - GNU Octave
- MATLAB - Simulink
- MATLAB 有用资源
- MATLAB - 快速指南
- MATLAB - 有用的资源
- MATLAB - 讨论
MATLAB - Matrix Multiplication
Consider two matrices A and B. If A is an m x n matrix and B is an n x p matrix, they could be multiplied together to produce an m x p matrix C. Matrix multiplication is possible only if the number of columns n in A is equal to the number of rows n in B.
In matrix multiplication, the elements of the rows in the first matrix are multiplied with corresponding columns in the second matrix.
Each element in the (i, j)th position, in the resulting matrix C, is the summation of the products of elements in ith row of first matrix with the corresponding element in the jth column of the second matrix.
Matrix multiplication in MATLAB is performed by using the * operator.
Example
Create a script file with the following code −
a = [ 1 2 3; 2 3 4; 1 2 5] b = [ 2 1 3 ; 5 0 -2; 2 3 -1] prod = a * b
When you run the file, it displays the following result −
a = 1 2 3 2 3 4 1 2 5 b = 2 1 3 5 0 -2 2 3 -1 prod = 18 10 -4 27 14 -4 22 16 -6