Change initial conditions to maximize Rsquared

1 次查看(过去 30 天)
For example is there a way to tell matlab + or - these varaibles (X,Y,Z) by 0.001 as needed to maxamize the R squared value??
Such as a while loop that looks like this? this is a made up script for an example
X1 = 1
Y1 = 1
Z1 = 1
X2 = 1
Y2 = 1
Z2 = 1
Fit = fitlm(A,B);
R2 = Fit.Rsquared.Ordinary; ( gets an R squared lets assume not 1)
while R2 < 0.8
dx = 0.001 ( I want this dx to be + or - 0.001 somehow in order to maxamize R squared (R2))
X1 = X1 +dx
Y1 = Y1+dz
Z1 = Z1+dx
..... same for X2 Y2 Z2
A = sin(X1+Y1+Z1)
B=sin(X2+Y2+Z2)
Fit = fitlm(A,B);
R2 = Fit.Rsquared.Ordinary;
end

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by