Converting symbolic boolean to MATLAB boolean
4 次查看(过去 30 天)
显示 更早的评论
Hi,
I have a symbolic expression that can be evaluated to true / false, and I would like to get that result back to MATLAB.
This is what I have tried:
>> sym('1>0')
ans =
0 < 1
>> simplify(sym('1>0'))
ans =
TRUE
>> double(simplify(sym('1>0')))
??? Error using ==> eval
Undefined function or variable 'TRUE'.
Error in ==> sym.sym>sym.double at 937
X = eval(Xstr);
>> logical(simplify(sym('1>0')))
??? Error using ==> logical
Conversion to logical from sym is not possible.
>>
Thanks Joan
采纳的回答
Walter Roberson
2011-5-27
strcmp(char(sym('TRUE')),'TRUE')
3 个评论
Walter Roberson
2011-5-27
piecewise() or _if() might be easiest. Neither of those appear to have MATLAB interfaces, though, so you might need to use evalin().
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Assumptions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!