|
Thanks for the reply and your advice!
We’ve now updated the code according to your descriptions, however we now get another error: “Error using runmyfun1 (line 3) Not enough input arguments.”
At line 3 it’s the following code; [x,fval] = fmincon(@myfun1,x0,A,b,[],[],lb,ub,options);
x0 is = [3,0.1, 3,0.25,0.5]
What could this error depend on?
Thanks in advance for your help!
Below follows the whole code as it is in our runmyfun1.m file:
function [x,fval] = runmyfun1(x0)
[x,fval] = fmincon(@myfun1,x0,A,b,[],[],lb,ub,options);
function f = myfun1(x,cdev,F,pdev)
f = ((cdev)+(pdev))+((x(5).*(exp(x(1)+.5.*(x(3).^2)))+(1-x(5)).*(exp(x(2)+.5.*x(4).^2))-F)^2);
for m=1;length(chat);
cdev=(c(m)-chat(m)).^2;
sum(cdev);
for n=0,length(phat);
pdev=(p(n)-phat(n)).^2;
sum(pdev);
end
end
function c = tcall (r, dtmc, q1, q2, q3, q4, kc)
c=exp(-r.*dtmc).*(x(5)).*(exp(x(1)+.5.*(x(3).^2).*(q1)-kc.*(q2)))+(1-x(5)).*(exp(x(2)+.5.*(x(4).^2).*(q3)-kc.*(q4)));
myfun1=@tcall;
function p = tput (r, dtmp, q1, q2, q3, q4, kp)
p=exp(-r.*dtmp).*(x(5).*(exp(x(1)+.5.*(x(3).^2).*((-1)*q1)-kp.*((-1).*q2))))+(1-x(5)).*(exp(x(2)+.5.*(x(4).^2).*((-1).*q3)-kp.*((-1).*q4)));
myfun1=@tput;
function q1 = qett (d1)
q1=cdf('normal',d1,0,1);
tput=@qett;
tcall=@qett;
function q2 = qtva (d2)
q2=cdf('normal',d2,0,1);
tput=@qtva;
tcall=@qtva;
function q3 = qtre (d3)
q3=cdf('normal',d3,0,1);
tput=@qtre;
tcall=@qtre;
function q4 = qfyra (d4)
q4=cdf('normal',d4,0,1);
tput=@qfyra;
tcall=@qfyra;
function d2 = dtva (d1, x)
d2=d1-x(3);
qett=@dtva;
function d4 = dfyra (d3, x)
d4=d3-x(4);
qfyra=@dfyra;
function d1 = dett (k, x)
d1=(-log(k)+x(1)+x(3).^2)./x(3);
dtva=@dett;
function d3 = dtre (k, x)
d3=(-log(k)+x(2)+x(4).^2)./x(4);
dfyra=@dtre;
end
end
end
end
end
end
end
end
end
end
end
end
|