Hi Alan, thanks again for your help.
I still have problems. I update you about my progress...
The objective function is this one:
#########
>>>bill.m
function f = bill(x,d,q)
r = x(1)
s = x(2)
f = -(-((r-d)^2+(s-d)^2)+(q-d)^2)
#########
The constraint function:
#########
>>>contraint.m
function [c, ceq] = constraint(x,k,q)
c(1) = (-(p(x(1)-k)^2+(1-p)(x(2)-k)^2)+(q-k)^2);
ceq = [ ];
end
#########
My unknown parameters are q, k and d. At the moment I want to fix their values to some fictitious constants (when I will succeed on it I will implement cycles on those parameters).
What I wrote in the command line is:
#########
q=0
d = 6
k = 3
f = @(x)bill(x,d,q)
x0 = [0;0]
[x,fval]=fmincon('bill',x0,[],[],[],[],[],[],'constraint')
#########
Matlab returns this error:
#########
??? Input argument "d" is undefined.
Error in ==> bill at 4
f = -(-((r-d)^2+(s-d)^2)+(q-d)^2)
Error in ==> fmincon at 574
initVals.f = feval(funfcn{3},X,varargin{:});
Caused by:
Failure in initial user-supplied objective function evaluation. FMINCON
cannot continue.
#########
What am I doing wrong?
I really appreciate your help.
Cheers,
Camilla
Alan_Weiss <aweiss@mathworks.com> wrote in message
> You must have the values of d and s in your workspace, so MATLAB can
> access them. Perhaps I misunderstand you when you say they are
> "endogenous" to your model. To me, that means they are just constants.
> You can include arbitrary constants and other data using the techniques
> described here:
> http://www.mathworks.com/help/optim/ug/passing-extra-parameters.html
>
> You can use the same techniques for your nonlinear constraints.
>
> Good luck,
>
> Alan Weiss
> MATLAB mathematical toolbox documentation
I still have problems. I update you about my progress...
The objective function is this one:
#########
>>>bill.m
function f = bill(x,d,q)
r = x(1)
s = x(2)
f = -(-((r-d)^2+(s-d)^2)+(q-d)^2)
#########
The constraint function:
#########
>>>contraint.m
function [c, ceq] = constraint(x,k,q)
c(1) = (-(p(x(1)-k)^2+(1-p)(x(2)-k)^2)+(q-k)^2);
ceq = [ ];
end
#########
My unknown parameters are q, k and d. At the moment I want to fix their values to some fictitious constants (when I will succeed on it I will implement cycles on those parameters).
What I wrote in the command line is:
#########
q=0
d = 6
k = 3
f = @(x)bill(x,d,q)
x0 = [0;0]
[x,fval]=fmincon('bill',x0,[],[],[],[],[],[],'constraint')
#########
Matlab returns this error:
#########
??? Input argument "d" is undefined.
Error in ==> bill at 4
f = -(-((r-d)^2+(s-d)^2)+(q-d)^2)
Error in ==> fmincon at 574
initVals.f = feval(funfcn{3},X,varargin{:});
Caused by:
Failure in initial user-supplied objective function evaluation. FMINCON
cannot continue.
#########
What am I doing wrong?
I really appreciate your help.
Cheers,
Camilla
Alan_Weiss <aweiss@mathworks.com> wrote in message
> You must have the values of d and s in your workspace, so MATLAB can
> access them. Perhaps I misunderstand you when you say they are
> "endogenous" to your model. To me, that means they are just constants.
> You can include arbitrary constants and other data using the techniques
> described here:
> http://www.mathworks.com/help/optim/ug/passing-extra-parameters.html
>
> You can use the same techniques for your nonlinear constraints.
>
> Good luck,
>
> Alan Weiss
> MATLAB mathematical toolbox documentation