怎么用R语言求矩阵的迹?如题

2023-04-27

问题描述:

怎么用R语言求矩阵的迹?
如题


最佳答案:

a=matrix(1:9,nrow=3)
tr = 0
for(i in 1:nrow(a))
tr = tr + a[i, i]
tr

相关推荐