我的脚本中有fmincon
优化,可以对齐笛卡尔坐标系中的几何曲面。
function fDiffLiRe = opt_Teil2(phi)
global xNeg yNeg xPos yPos stepsX yyPos yyNeg fLiDiff fReDiff fistLi fistRe fsollLi fsollRe xxxPos xxxNeg yyyPos
global yyyNeg
global interpolationsmethode
%Coordinates are rotated through Phi
%left geometrical shape rotated
xxxNeg=xNeg*cos(phi)+yNeg*sin(phi);
yyyNeg=-xNeg*sin(phi)+yNeg*cos(phi);
%right geometrical shape rotated
xxxPos=xPos*cos(phi)+yPos*sin(phi);
yyyPos=-xPos*sin(phi)+yPos*cos(phi);
%rotated coordinates are interpolated
yyPos = interp1(yyyPos,xxxPos,stepsX, interpolationsmethode);
yyNeg = interp1(yyyNeg,xxxNeg,stepsX, interpolationsmethode);
%area of each geometrical shape is calculated
%left
fistLi=trapz(stepsX,yyNeg);
%target size of the left shape
fsollLi=-0.93;
fLiDiff=fsollLi-fistLi;
%right
fistRe=trapz(stepsX,yyPos');
%target size of the right shape
fsollRe=0.93
fReDiff=fsollRe-fistRe;
%sum of the Deviation of the target sizes is minimized
fDiffLiRe=(fReDiff+fLiDiff)^2;
end
优化正常,并返回正确旋转的坐标yyPos
和yyNeg
。我现在想要返回坐标旋转过的总角度phi
。我怎样才能做到这一点?变量phi
仅显示优化的最后一步