我想优化一个坐标系与另一个坐标系之间的计算(3D)。我必须通过多次计算(线性,二次等)找到一个矩阵。
现在我有一个无法正常工作的代码,因为R只能计算数字值,而不能计算参数。难道我做错了什么?我很傻吗(我是R中的新手)。
感谢您的帮助。
这是我的代码:
setwd("C:/Users/Tobi_Laptop/Documents/Tobi/Studium/6. Semester/Farbmetrik/Projekt/Umrechnung")
Messwerte <- read.csv2("Messwerterot.csv", sep=";", dec=",")
DeltaL_lin1_fun <- function(Lab_Werte, par){with(Lab_Werte, sum((Messwerte$L99o.soll - (Messwerte$R*par[1]+Messwerte$G*par[2] + Messwerte$B*par[3]))^2))}
L_lin1_opt <- optimx(par=c(1,1,1), fn=DeltaL_lin1_fun, Lab_Werte=Messwerte,mehtod="BGFS")
Deltaa_lin1_fun <- function(Lab_Werte, par){with(Lab_Werte, sum((Messwerte$a99o.soll - (Messwerte$R*par[1]+Messwerte$G*par[2] + Messwerte$B*par[3]))^2))}
a_lin1_opt <- optimx(par=c(1,1,1), fn=Deltaa_lin1_fun, Lab_Werte=Messwerte,mehtod="BGFS")
Deltab_lin1_fun <- function(Lab_Werte, par){with(Lab_Werte, sum((Messwerte$b99o.soll - (Messwerte$R*par[1]+Messwerte$G*par[2] + Messwerte$B*par[3]))^2))}
b_lin1_opt <- optimx(par=c(1,1,1), fn=Deltab_lin1_fun, Lab_Werte=Messwerte,mehtod="BGFS")
M_lin1<-matrix(c(L_lin1_opt$p1,L_lin1_opt$p2,L_lin1_opt$p3,a_lin1_opt$p1,a_lin1_opt$p2,a_lin1_opt$p3,b_lin1_opt$p1,b_lin1_opt$p2,b_lin1_opt$p3), nrow=3, byrow=TRUE)
colnames(M_lin1)<-c("p1","p2","p3")
rownames(M_lin1)<-c("L","a","b")
M_lin1
我期望值从1,0528E-07到17(Excel求解器)
如何将RMD文件或Excel文件上传到Stackoverflow?