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 Comment

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

Sign in to comment.

Answers (0)

Asked:

on 2 Dec 2017

Commented:

on 2 Dec 2017

Community Treasure Hunt

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

Start Hunting!