write function for using optimization app

i try to use function for optimization app and i keep getting same error
Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.
this is my code
function [f,w1,w2,beta0,beta1,gamma0,gamma1,a,b,x,y]=myfun(p)
%every equation must name in function
w1 = normrnd(0,1,[1 100]);
w2 = normrnd(0,1,[1 100]);
beta0 = 0.5;
beta1 = 1;
gamma0= 0.5;
gamma1= 1;
a = exp(beta0 +beta1.*w1);
b = exp(gamma0+ gamma1.*w2);
x = exprnd(a);
y = exprnd(b);
f= exp(p(1)+p(2).*w1-p(3)-p(4).w2 )./ (1+exp(p(1)+p(2).*w1-p(3)-p(4).w2));
end

1 个评论

That code looks okay. Perhaps the problem is in the code you use to call it.

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Surrogate Optimization 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by