using relational operators with the symbolic math toolbox?

2 ビュー (過去 30 日間)
Sarla
Sarla 2011 年 2 月 19 日
is there anyway i can use relational operators with the symbolic math toolbox? i have read the other answer for the same question and it wasn't very clear to me. could someone please explain?

採用された回答

Walter Roberson
Walter Roberson 2011 年 2 月 19 日
Yes, there is a MuPad call named "is" that will test a condition. It is not strictly constrained to numeric relations: it can test properties such as data types, and when assumptions have been applied, it may be able to decide relationships between expressions that involve symbolic variables. Most of the time, though, expressions that involve symbolic variables without assumptions are not decidable, and is() will return false for those cases.
Coding the relational expression at the Matlab level can be a problem, so you usually end up having to express it as a string and using subs() to transfer the values from the Matlab engine to the symbolic engine.

その他の回答 (1 件)

Andrew Newell
Andrew Newell 2011 年 2 月 19 日
If you have assigned numeric values to your symbolic variables, you could do something like this:
syms x y
x = 1; y = 2;
if double(y) > double(x)
disp('True is true!')
else
disp('Doubleplusungood.')
end

カテゴリ

Help Center および File ExchangeProperties and Assumptions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by