Path: news.mathworks.com!not-for-mail From: Alan_Weiss <aweiss@mathworks.com> Newsgroups: comp.soft-sys.matlab Subject: Re: Non linear optimization problem Date: Tue, 10 Sep 2013 09:30:14 -0400 Organization: MathWorks Lines: 34 Message-ID: <l0n6t6$l34$1@newscl01ah.mathworks.com> References: <l0m5no$5gn$1@newscl01ah.mathworks.com> Reply-To: aweiss@mathworks.com NNTP-Posting-Host: ah-aweiss.dhcp.mathworks.com Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: newscl01ah.mathworks.com 1378819814 21604 172.28.17.56 (10 Sep 2013 13:30:14 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Tue, 10 Sep 2013 13:30:14 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 In-Reply-To: <l0m5no$5gn$1@newscl01ah.mathworks.com> Xref: news.mathworks.com comp.soft-sys.matlab:802168 On 9/10/2013 12:04 AM, Bozorgmehr wrote: > Hi all > I am trying to solve a Maximum Likelihood estimation. I tried fminnunc > function in matlab optimization toolbox. However, there is an error: > Error using optimfcnchk (line 288) > FUN must be a function, a valid string expression, or an inline > function object. > > Error in fminunc (line 239) > funfcn = > optimfcnchk(FUN,'fminunc',length(varargin),funValCheck,gradflag,hessflag); > My objective function is quite complicated. I have to write for loop > in my function to sum likelihoods. However,when I call objective > function, there is no error, and for x0 I have a very quick answer. > My variable,X, which should be optimized, is a matrix. In first lines > of my objective function, I defined new variables, using X. For > instance, I defined nu=x(1,1), and used "nu" rather than x(1,1) in > objective function. Is this ok? > Could you please help me? > Thanks I'm sorry, but you have not given us enough information to diagnose what is going wrong. Please give the following: * Your function call, something like [x,fval] = fminunc(@myfun,x0,options); Also, and this is important, the first line of your objective function, something like function fval = myfun(x) * Your options, something like options = optimset('Algorithm','quasi-newton'); * The entire error listing, not just one line of it. Alan Weiss MATLAB mathematical toolbox documentation