###第一周:R基础 rm(list = ls()) #ctr+L###矩阵相乘,函数diag()a=matrix(1:12,nrow=3,ncol=4)b=matrix(1:12,nrow=4,ncol=3)a%*%ba=matrix(1:16,nrow=4,ncol=4)diag(a)#返回对角线元素diag(diag(a))diag(4)#对角线为1的单位矩阵###矩阵求逆,函数rnorm(),solve()a=matrix(rnorm(16),4,4)#产生4*4的随机数solve(a…