How to factor out several variables in a big equation?

10 ビュー (過去 30 日間)
Chris
Chris 2016 年 2 月 26 日
コメント済み: Tom Teasdale 2022 年 5 月 27 日
Dear community, I have a very big equation (almost 1000 terms) with several variables I'm interested in. Let's call those x1, x2, x3, x4, x5 and so on. What I'd like to do is to factor out those variables - all at a time. This should be easy because the variables are linearly independent. The equation should look something this: x1(...) + x2(...) + x3(...) + x4(...) + x5(...) + ... = RHS. So, I would simply like to collect all the coefficients for the different variables. Normally, I would do it by hand but in this case that would be way too much work. Likewise, the susceptibility to errors would be too high... Can anybody help me with this? I cannot tell MATLAB what to do. I have the whole equation as a symbolic expression and tried collect() and factor() which didn't seem to do the trick. Ultimately I want to build up a system of linear equations which can be solved numerically later on. This however shouldn't be a problem once I have the upper representation of the equation. Thanks for your help!

採用された回答

Toby Howison
Toby Howison 2016 年 2 月 26 日
Use:
collect(expression, [x1,x2,x3,etc..])
But copy your expression into MuPad and use that environment, I had the same problem.
  2 件のコメント
Chris
Chris 2016 年 2 月 28 日
Thanks! It worked like a charm :)
Tom Teasdale
Tom Teasdale 2022 年 5 月 27 日
Thanks a lot!

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by