Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: minimizing a dynamic function
Date: Mon, 16 Aug 2010 20:45:23 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 95
Message-ID: <i4c813$clq$1@fred.mathworks.com>
References: <i48snb$fjt$1@fred.mathworks.com> <i491f8$i98$1@fred.mathworks.com> <i492f4$lj5$1@fred.mathworks.com> <i49498$haf$1@fred.mathworks.com> <i495m8$g5g$1@fred.mathworks.com> <i4bfsp$pui$1@fred.mathworks.com> <i4bnk8$sj7$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1281991523 12986 172.30.248.38 (16 Aug 2010 20:45:23 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 16 Aug 2010 20:45:23 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2376520
Xref: news.mathworks.com comp.soft-sys.matlab:662525




Just a little question:



The following code works ALMOST


j=2;
x0 = 0.5*ones(j,1);   %starting vektor [0.5;0.5]
lb = zeros(j,1);      %lower boundaries [0;0];
ub=  ones(j,1);       %upper boundaries [1;1]; 
Aeq= ones(1,j); 
beq= 1; 

f=@(x)0;
for i=1:j
     f=@(x) f(x)+x(i);
end


%----------------------------------------------------------

g=@(x)0;
for i=1:j
     g=@(x) (g(x)+x(i)^2);
end

%---------------------------------------------------------




h=@(x) f(x)/g(x);

[x,fval,exitflag]=fmincon(h,x0,[],[],Aeq,beq,lb,ub)

 



Because of  j=2 Matlab should find the Minumum

of

(x(1)+x(2))/(x(1)^2+x(2)^2)

Constraints
0<=x(1)<=1   und   0<=x(2)<=1
x(1)+x(2)=1

Start=[0.5,0.5]




 

The outcome is:

x =

    0.5000
    0.5000


fval =

    2.0000


exitflag =

     1





This can't be the right solution.


Even x(1)=0.1 , x(2)=0.9  

leads to a smaller value


What is th eproblem there?

Thank you very much,


Dominik