Ich versuche, den folgenden Code auszuführen, ein System von nicht-linearen Gleichungen zu lösen R mit:korrekte Art und Weise fsolve in R verwenden (pracma Paket)
library(pracma)
t <- read.csv("values-try.csv", header=F, sep=",")
x0 <- as.matrix(c(0, 1, 0, 1, 0, 1))
Gr <- 9.807
F <- function (x) {
x1 <- x[1]; x2 <- x[2]; x3 <- x[3]; x4 <- x[4]; x5 <- x[5]; x6 <- x[6]
as.matrix(c((t[1,1] - x1)^2/x2^2 + (t[1,2] - x3)^2/x4^2 + (t[1,3] - x5)^2/x6^2 - Gr^2,
(t[2,1] - x1)^2/x2^2 + (t[2,2] - x3)^2/x4^2 + (t[2,3] - x5)^2/x6^2 - Gr^2,
(t[3,1] - x1)^2/x2^2 + (t[3,2] - x3)^2/x4^2 + (t[3,3] - x5)^2/x6^2 - Gr^2,
(t[4,1] - x1)^2/x2^2 + (t[4,2] - x3)^2/x4^2 + (t[4,3] - x5)^2/x6^2 - Gr^2,
(t[5,1] - x1)^2/x2^2 + (t[5,2] - x3)^2/x4^2 + (t[5,3] - x5)^2/x6^2 - Gr^2,
(t[6,1] - x1)^2/x2^2 + (t[6,2] - x3)^2/x4^2 + (t[6,3] - x5)^2/x6^2 - Gr^2), ncol = 1)
}
fsolve(F, x0)
Ich halte die folgende Fehlermeldung erhalten:
Error in if (norm(s, "F") < tol || norm(as.matrix(ynew), "F") < tol) break :
missing value where TRUE/FALSE needed
Calls: fsolve -> broyden
Execution halted
Hinweise oder Lösung des Fehlers?
Die Werte-try.csv sieht wie folgt aus:
0.1191419256974832, -0.2806359683994824, -9.755712465258934
0.3194200198415491, 0.05681698915395282, -9.711375649078391
0.05320046522270569, 0.21071993729858585, -9.711942750423542
0.056291795600583824, 0.20746318577998762, -9.697096562782926
-0.18870002789891743, -0.03873042128470452, -9.70831243701548
0.13239301222057243, -9.790554976542873, -0.9744148062871234