利用matlab进行向量的四则运算
matlab是矩阵运算软件,利用它可以进行矩阵的所有计算,本例分享如何使用matlab进行向量间的加减乘除四则运算。
工具/原料
matlab
简单四则运算
1、加(减)法。同型矩阵直接相加即可。如附图所示,利用randperm函数生成两个个行向量(10个0-100之间的整数作为元素),然后直接相加(减法)即可。

2、若是不同型,则要满足矩阵加(减)法的规则,例如将某个矩阵的所有元素都加1,如附图所示,利用rand函数生成一个4行5列的服从(0,1)的正太分布矩阵,然后*10后,利用floor进行一个取整,最后直接加1即可。


3、Cross-计算向量叉乘。cross Vector cross product. C = cross(A,B) returns the cross product of the vectors A and B. That is, C = A x B. A and B must be 3 element vectors. C = cross(A,B) returns the cross product of A and B along the first dimension of length 3. C = cross(A,B,DIM), where A and B are N-D arrays, returns the cross product of vectors in the dimension DIM of A and B. A and B must have the same size, and both SIZE(A,DIM) and SIZE(B,DIM) must be 3. Class support for inputs A,B: float: double, single
