フィルターのクリア

Error/Confusion with Simplifying Symbolic Expressions

1 回表示 (過去 30 日間)
Kyle McLaughlin
Kyle McLaughlin 2021 年 9 月 4 日
回答済み: Sulaymon Eshkabilov 2021 年 9 月 4 日
Hi, I am trying to work with a symbolic expression and am using the simplify command. My expressions are as follows:
syms x y
%ODE components
M = 3*x*y^2 + 2*y;
N = 2*x^2*y + x;
%Adding integration factor
M_intfact = simplify(M*g)
N_intfact = simplify(N*g)
I am applying an integration factor to these after a series of steps which I have neglected to include bc that code already does what I want...
My issue is that when I apply the integration factor, in this case it is simply 'x', the simplify command does not distribute it through out the expression. Rather it sticks it infront of the whole thing and leaves it there and shuffles around other variables.
%Results:
M_intfact = x*y*(3*x*y + 2)
N_intfact = x^2*(2*x*y + 1)
If I chose to not include the simplify command then the results look like this:
M_intfact = x*(3*x*y^2 + 2*y)
N_intfact = x*(2*y*x^2 + x)
I expect that the simplified expressions should look like these:
I feel like this is strange behavior so if anyone has a clue that would be great!
  1 件のコメント
Kyle McLaughlin
Kyle McLaughlin 2021 年 9 月 4 日
UPDATE: I just found out that the expand command exists and I think that may have solved my probelm. If there are other solutions please provide input!

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

回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 9 月 4 日
You can also use: collect()

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by