0

I'm trying to invoke an fgoalattain function (computing a function minimum with a goal-attainment algorithm) in MATLAB. According to documentation, it should look like this:

fun =@(x)[sum(cv>x)./25];
goal = 2.72;
W = 0;
xo = 17.12;
   o = optimoptions('fgoalattain','EqualityGoalCount',1);
   [x,fval,attainfactor,exitflag,output] = fgoalattain(fun,xo,goal,W,[],[],[],[],[],[],[],o);
 

matlab R2017b instead returns the following:

x =
  17.120000000000001
fval =
   0.640000000000000
attainfactor =
  0.684912109342071
exitflag =
     0
output = 
  struct with fields:
         iterations: 15
          funcCount: 203
       lssteplength: -6.103515625000000e-05
           stepsize: 1.269531249938965e-04
          algorithm: 'active-set'
      firstorderopt: []
    constrviolation: 2.079999999900000

I have manually calculated the goal seek in Excel, but it is different from the MATLAB result.Threshlod or x obtained in Excel is correct.But the MATLAB X coefficient is not correct. enter image description here enter image description here

The value of x should be 5.94, but it(matlab) returns the value xo! This is clearly wrong and I have no idea why. Please help. The data used in the function

karbalaee
  • 15
  • 5

0 Answers0