how to set the domain of a function

11 vues (au cours des 30 derniers jours)
Patience Shamaki
Patience Shamaki le 18 Juil 2021
Commenté : Patience Shamaki le 19 Juil 2021
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

Réponse acceptée

Walter Roberson
Walter Roberson le 19 Juil 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 commentaires
Walter Roberson
Walter Roberson le 19 Juil 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]);
Patience Shamaki
Patience Shamaki le 19 Juil 2021
Okay, thank you very much!!

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by