将向量除以矩阵

时间:2019-05-02 09:38:55

标签: r matrix division

我想翻译Matlab代码,因此有点困扰。我想计算A / B,其中A是1x3向量,B是3x3矩阵。在Matlab中,它可以完美运行。解决方案应该是C。

我考虑过将公式更改为

AB ^(-1)

我忘记了什么?与Matlab A/B等价的是什么?

A<-structure(c(0.203087815504433, -0.185526315789458, 2.06128903508772), .Dim = c(1L, 3L))
B<-structure(c(0.162362619308917, 0.00102409360829869, 0.0271730132253801, 
           0, 0.010825744280011, 0.00830177798871224, 0, 0, 0.0526477214917381), .Dim = c(3L, 3L))
C=c(-11.794,14.789,34.757)
A%*%solve(B)

编辑:     当我想简化示例时,我犯了一个错误.....我不知道自己做错了什么,矩阵对我来说看起来一样吗?为了完整起见:

Sigma=matrix(c(0.40294,0,0,-0.032001,0.10405,0,0.16484,-0.091114,0.22945),nrow=3,byrow=TRUE)
epsilon_temp=c(0.50401,-1.6281,7.975)
covariance=matrix(c(0.16236, -0.012895, 0.066422, -0.012895,0.01185,-0.014755, 0.066422,-0.014755,0.088123),nrow=3)

t(Sigma%*%epsilon_temp)%*%solve(covariance) #right solution

a<-t(Sigma%*%epsilon_temp)
b<-covariance
a%*%solve(b) #right solution

0 个答案:

没有答案