How to create a symbolic variable at special range.
71 views (last 30 days)
Show older comments
I would like to create the symbolic variable 'x', which belongs to subspace [0. , 1.] of 'real 1d space'. I found that, "x=sym('x','real')" but it is not general as I would like "x=sym('x','[a, b]')", where 'a' and 'b' are real numbers with constrain ' a <= b '. Thanks.
0 Comments
Answers (2)
Walter Roberson
on 20 Sep 2011
Symbolic computations do not check constraints in some (common) operations, so although you could use assume() to add the constraint, there are more robust ways.
What you can do instead in MuPAD is to use
Dom::Interval
. This will have to be done at the MuPAD level, as this interface has not been exported to MATLAB. For example,
x = feval(symengine,'Dom::Interval', a, b);
3 Comments
Walter Roberson
on 18 May 2020
You would not do that by putting assumptions on t. You would do something like
symst
f(t) = exp(t)
fplot(f, [eps(realmin) 10*(1-eps)])
If it was especially important that you reach arbitrarily close to the limits without being
at
the limits, then use piecewise:
symst
f(t) = piecewise(0 < t & t < 10, exp(t));%不否则关闭意味着定义
fplot(f, [0 10])
Xiangjie Yan
on 18 May 2020
hi Samouil,
try
assume(x,'positive');
assume(1-x,'positive');
hope this can help :)
0 Comments
See Also
下载188bet金宝搏
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!