How to rename lumped constant terms within parenthesis

4 ビュー (過去 30 日間)
Toby Howison
Toby Howison 2016 年 2 月 4 日
コメント済み: Toby Howison 2016 年 2 月 8 日
Hi Guys
I have some huge symbolic equations (multiple pages) in the variables (x,y,z), of the form:
Eq1(x,y,z) = x*y*(.....) + y*z*x*(....) ....(many pages)
where the brackets contain constant symbolic terms (e.g. they are just constant coefficients), e.g.:
(Q23*l5*l6*m4 + Q22*l5*m4*m6)
Is there anyway to automatically go through each equation and delete / abbreviate the bracketed coefficients to a single letter? Currently I am doing it manually but it takes so long..! Maybe using a find and replace function?
Thanks
Toby

採用された回答

Walter Roberson
Walter Roberson 2016 年 2 月 4 日
The easiest way to do this is to go in to the symbolic engine level and use subsex
syms QQ
result = feval(symengine, 'subsex', Eq1(x,y,z), (Q23*l5*l6*m4 + Q22*l5*m4*m6), QQ);
Note that this will be an expression rather than a function. I am not sure if you would be able to execute this on the function returning a function, but you could try -- list Eq1 instead of E1(x,y,z) as the argument.

その他の回答 (0 件)

製品

Community Treasure Hunt

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

Start Hunting!

Translated by