How to set an assumption on a symbolic variable in a symbolic expression?

1 回表示 (過去 30 日間)
xv cheng
xv cheng 2018 年 8 月 6 日
コメント済み: Walter Roberson 2018 年 8 月 6 日
Hello!
I want to solve some equations using symbolic math toolbox.I only get some strings like '3*x1-2*x2'.x1,x2 should be positive numbers.
I can use str2sym(string) to get a symbolic expression 3*x1-2*x2.
Then, how to set an assumption on x1,x2 in the symbolic expression? The assumption is x1>0,x2>0.
Thank you in advance

採用された回答

Stephan
Stephan 2018 年 8 月 6 日
編集済み: Stephan 2018 年 8 月 6 日
Hi,
you can use the assume function for this purpose.
Note the section for multiple assumptions which requires assumeAlso to work properly.
Best regards
Stephan
  1 件のコメント
Walter Roberson
Walter Roberson 2018 年 8 月 6 日
You can symvar to get the variable names and arrayfun assume()

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAssumptions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by