how to set the domain of a function

13 views (last 30 days)
Hello please how do I set the domain for my function :
f(x1,x2)= -9*x(1) - 10*x(2) + 10*(-log(100-x(1)-x(2))-log(x(1))-log(x(2))-log(50-x(1)+x(2)));
X{(x1,x2)|x1>0,x2>0,x1+x2<100,x1-x2<50}
thanks

Accepted Answer

Walter Roberson
Walter Roberson on 19 Jul 2021
syms x [1 2]
f(x) = piecewise(x(1)>0 & x(2)>0 & x(1)+x(2) <100 & x(1)-x(2)<50, -9*x(1) - 10*x(2) + 10*(-log(100-x(1)-x(2))-log(x(1))-log(x(2))-log(50-x(1)+x(2))), NaN)
f(x1, x2) = 
fsurf(f, [-5 105 -5 105] ); xlim([-5 105]); ylim([-5 105])
  4 Comments
Walter Roberson
Walter Roberson on 19 Jul 2021
syms x [1 2]
Notice the space.
However I see now that you are using an older release. You would need
x = sym('x', [1 2]);

Sign in to comment.

More Answers (0)

Products


Release

R2015a

Community Treasure Hunt

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

Start Hunting!