MATLAB矩阵计算。

18 views (last 30 days)
bacesa
bacesa on 21 Nov 2022
Answered: dajihov on 21 Nov 2022
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
这是怎么计算的啊?

Accepted Answer

dajihov
dajihov on 21 Nov 2022
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]

More Answers (0)

Categories

Find more on Matrix Indexing in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!