1

这就是问题所在:我想计算 3x3 矩阵的逆矩阵。我尝试使用solve(J),但它给出了一条错误消息:

solve.default(J) 中的错误:“a”必须是数字矩阵。

这是矩阵J和代码:

T1<-20
T2<-50
T3<-50
T4<-50
T5<-350

        df1dx1<- Deriv(-(14.6+0.0635*(T2+T1))*T2-(14.6+0.0635*(T2+T1))*T1+(14.6+0.0635*(T3+T2))*T3-(14.6+0.0635*(T3+T2))*T2, "T2")
        df1dx2<- Deriv(-(14.6+0.0635*(T2+T1))*T2-(14.6+0.0635*(T2+T1))*T1+(14.6+0.0635*(T3+T2))*T3-(14.6+0.0635*(T3+T2))*T2, "T3")
        df1dx3<- Deriv(-(14.6+0.0635*(T2+T1))*T2-(14.6+0.0635*(T2+T1))*T1+(14.6+0.0635*(T3+T2))*T3-(14.6+0.0635*(T3+T2))*T2, "T4")
        df2dx1<- Deriv(-(14.6+0.0635*(T3+T2))*T3-(14.6+0.0635*(T3+T2))*T2+(14.6+0.0635*(T4+T3))*T4-(14.6+0.0635*(T4+T3))*T3,"T2")
        df2dx2<- Deriv(-(14.6+0.0635*(T3+T2))*T3-(14.6+0.0635*(T3+T2))*T2+(14.6+0.0635*(T4+T3))*T4-(14.6+0.0635*(T4+T3))*T3,"T3")
        df2dx3<- Deriv(-(14.6+0.0635*(T3+T2))*T3-(14.6+0.0635*(T3+T2))*T2+(14.6+0.0635*(T4+T3))*T4-(14.6+0.0635*(T4+T3))*T3,"T4")
        df3dx1<- Deriv(-(14.6+0.0635*(T4+T3))*T4-(14.6+0.0635*(T4+T3))*T3+(14.6+0.0635*(T5+T3))*T5-(14.6+0.0635*(T5+T4))*T4,"T2")
        df3dx2<- Deriv(-(14.6+0.0635*(T4+T3))*T4-(14.6+0.0635*(T4+T3))*T3+(14.6+0.0635*(T5+T3))*T5-(14.6+0.0635*(T5+T4))*T4,"T3")
        df3dx3<- Deriv(-(14.6+0.0635*(T4+T3))*T4-(14.6+0.0635*(T4+T3))*T3+(14.6+0.0635*(T5+T3))*T5-(14.6+0.0635*(T5+T4))*T4,"T4")

    J<-matrix(c(df1dx1,df1dx2,df1dx3,df2dx1,df2dx2,df2dx3,df3dx1,df3dx2,df3dx3),nrow=3,ncol=3,byrow=TRUE)

invJ<- solve(J)  ##this gives the problem

有什么问题???非常感谢你们。Obs:我不能用 50 代替 T2、T3 和 T4,因为我需要重新计算多次更改 T2、T3 和 T4 值。

4

1 回答 1

0

正如错误消息所说。solve需要一个数字矩阵,但你已经给出了一个表达式矩阵。你可以做

eval(Deriv(-(14.6+0.0635*(T2+T1))*T2-(14.6+0.0635*(T2+T1))*T1+(14.6+0.0635*(T3+T2))*T3-(14.6+0.0635*(T3+T2))*T2, "T2"))

等计算数值

于 2016-06-03T03:16:12.957 回答