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
Walter Roberson
2017년 12월 2일
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!