Error using matlabfunction with piecewise functions and intervals
Show older comments
I am working with the symbolic toolbox and I am trying to generate a matlab function using the command matlabfunction() with gg as an input, where gg is a vector of piecewise functions as follows:
gg =
piecewise(x8 in Dom::Interval(-10, 10), x8, 10 <= x8, 10, x8 <= -10, -10)
x5
piecewise(10 < x8 | x8 < -10, 1, x8 in Dom::Interval([-10], [10]), 0)
piecewise(10 < x8 | x8 < -10, 1, x8 in Dom::Interval([-10], [10]), 0)
piecewise(80 <= t, 1, symtrue, 0)
Where t, x5, and x8 are symbolic variables.
When using the matlabfunction() command, as follows:
g = matlabFunction(gg,'Vars',{xNum,t},'File','genEqs/g');
I get the following errors and warnings:
Warning: Intervals ('DOM_INTERVAL' and 'Dom::Interval') not supported. Using element '0' instead.
Error using symengine
Unable to generate code for object 'x8 in t4'.
Error in sym/matlabFunction>mup2mat (line 404)
res = mupadmex('symobj::generateMATLAB',r.s,ano,spa,0);
Error in sym/matlabFunction>writeBody (line 516)
body = mup2mat(eqnk,false,sparseMat);
Error in sym/matlabFunction>writeMATLAB (line 452)
writeBody(fid,tvalues,sparseMat);
Error in sym/matlabFunction (line 183)
g = writeMATLAB(funs,file,varnames,outputs,body, opts.Optimize, opts.Sparse, opts.Comments);
Error in antiwindup_RUN_rrrr (line 241)
g = matlabFunction(gg,'Vars',{xNum,t},'File','genEqs/g');
However, if I use the following vector of piecewise functions, then the code works perfectly fine.
gg =
piecewise(x8 in Dom::Interval(-10, 10), x8, 10 <= x8, 10, x8 <= -10, -10)
x5
piecewise(10 < x8 | x8 < -10, 1, x8 in Dom::Interval([-10], [10]), 0)
piecewise(10.1 < x8 | x8 < -10.1, 1, x8 in Dom::Interval([-10.1], [10.1]), 0)
piecewise(80 <= t, 1, symtrue, 0)
What would be the reason of this? I can't figure it out. Is there a way to bypass this error?
Thank you in advance.
Nicolas
Accepted Answer
More Answers (0)
Categories
Find more on Assumptions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!