so I'm pretty new to MATLAB (so forgive the poor formatting), and have this problem.
I have u(x,y) = (2x)exp(-0.5x - y + 3) + y(3 - x - y). x, y > 0
How would I go about formatting this problem on MATLAB? All help appreciated, even if it's just linking a similar problem.
edit: currently have this code
f = @(x)2*x(1)*exp(-0.5*x(1)-x(2)+3)+x(2)*(3-x(1)-x(2)); g = @(x)-f(x); x0 = [0 0]; [xmin,gmin] = fminsearch(g,x0)
But I get that the maximum is infinite, how can I add the constraints of x>0 and y>0?
check the fmincon built in function. It finds the minimum of a constrained multivariable function. In your case, the constrains are only $x,y>0$, so you can specify: