MATLAB矩阵计算。

p=[1 2;1 2];
i=1:2;j=1:2;
s=sum(p(i,j)) 结果为s=2 4
s=sum(p(i,j)*p(i,j)) 结果为s=6 12
这是怎么计算的啊?

 采纳的回答

dajihov
dajihov 2022-11-21

0 个投票

p定义为一个2*2的矩阵,i为一个1*2的数组, j也是一个1*2的数组
p(i,j)就是就是相当于p矩阵本身,i,j为索引
sum(p(i,j))就是矩阵p的每列相加,就是[2,4]的矩阵
p(i,j)*p(i,j)又是一个2*2的矩阵[3 6;3 6],加上后就是[6 12]

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Matrix Indexing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!