Path: news.mathworks.com!not-for-mail
From: "Miroslav Balda" <miroslav.nospam@balda.cz>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Pls Help me to solve
Date: Sun, 8 Nov 2009 23:05:03 +0000 (UTC)
Organization: Miroslav Balda
Lines: 35
Message-ID: <hd7iqv$k6$1@fred.mathworks.com>
References: <hd1lmg$9g5$1@fred.mathworks.com>
Reply-To: "Miroslav Balda" <miroslav.nospam@balda.cz>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1257721503 646 172.30.248.38 (8 Nov 2009 23:05:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 8 Nov 2009 23:05:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 360709
Xref: news.mathworks.com comp.soft-sys.matlab:583421


SNIP

Hi,
I tried to solve your task, because it is rather complicated and I wanted to test my function LMFnlsq. However, the code of your function is rather confused. I have changed it into more lucid form. I am not sure whether I have not introduced an error.
Nevertheless , the following code solved the example in every attempt:

%   chirag.m    2009-11-08
[x,fval,cnt] = LMFnlsq(@myfun,rand(13,1),'Display',-20); % Call optimizer
format short e
x = x.*x

%  function  file:
function res = myfun(x)
x = x.*x;
sumx = sum(x(1:10));
res = [-22.47+log(x(1)/sumx)+3*x(11)+3*x(12)+8*x(13)
     -24.89+log(x(2)/sumx)+x(12)+2*x(13)
     -49.539+log(x(3)/sumx)+x(11)+2*x(12)
     -0.0574+log(x(4)/sumx)+2*x(13)
     -24.597+log(x(5)/sumx)+x(11)+x(12)
     -0.7027+log(x(6)/sumx)+x(11)+4*x(13)
     -32.59+log(x(7)/sumx)+2*x(11)+2*x(12)+4*x(13)
     -10.927+log(x(8)/sumx)+x(11)+x(12)+4*x(13)
     -4.635+log(x(9)/sumx)+2*x(11)+x(12)+6*x(13)
     -7.5188+log(x(10)/sumx)+2*x(11)+x(12)+4*x(13)
     3*x(1)+x(3)+x(5)+x(6)+2*x(7)+x(8)+2*x(9)+2*x(10)-0.1002
     3*x(1)+x(2)+2*x(3)+x(5)+2*x(7)+x(8)+x(9)+x(10)-1.6332
     8*x(1)+2*x(2)+2*x(4)+4*x(6)+4*x(7)+4*x(8)+6*x(9)+4*x(10)-3.3332];

The above code is much better organized, so that you may see, the form of equations. more over, what is once evaluated doesn't need be evaluated more times (sumx).
A solution has been reached always starting from a random initial estimate. If the accuracy is low, you may change the default one by a new option. Maybe that a requirement on positivness of all x is too strict, because the sum of squares dropped down only by one order. The reason could be also in an error in equations.

Hope it helps.

Mira