Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Non linear optimization problem

Subject: Non linear optimization problem

From: Bozorgmehr

Date: 10 Sep, 2013 04:04:08

Message: 1 of 2

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

Subject: Non linear optimization problem

From: Alan_Weiss

Date: 10 Sep, 2013 13:30:14

Message: 2 of 2

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

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us