필터 지우기
필터 지우기

Replacing variables with dummy variables

조회 수: 3 (최근 30일)
Roy Cornelissen
Roy Cornelissen 2018년 10월 2일
댓글: Star Strider 2018년 10월 2일
Hello everyone,
I have obtained a really long equation in Matlab containing a lot of variables. Is there a function in Matlab that can find N suitable dummy variables in which it can compress the found combinations of the actual variables?
Forex:
y(x) = A*log(x)+A*B*sin(x)+C*e^x
Where:
A = 2*a+b+5*c+2*d
B = c+d/a
C = a^2+c^4/b+b/2
(the actual equation is much longer)
Thanks in advance!
  댓글 수: 2
Adam
Adam 2018년 10월 2일
What is wrong with doing it in exactly the way you show? Creating your own variables that roll together a number of other variables into a simpler equation.
Roy Cornelissen
Roy Cornelissen 2018년 10월 2일
Since the obtained answer is: (D*((4*c1^2*((a*(4*t^2 - 2*t + 1))/2 - (16*a*t*(t - 1))/(3*pi)))/b^3 + (12*c2^2*((a*(4*t^2 - 2*t + 1))/2 - (16*a*t*(t - 1))/(3*pi)))/b^3 + (144*c3^2*((a*(4*t^2 - 2*t + 1))/2 - (16*a*t*(t - 1))/(3*pi)))/(5*b^3) + (12*c1*c2*((a*(4*t^2 - 2*t + 1))/2 - (16*a*t*(t - 1))/(3*pi)))/b^3 + (16*c1*c3*((a*(4*t^2 - 2*t + 1))/2 - (16*a*t*(t - 1))/(3*pi)))/b^3 + (36*c2*c3*((a*(4*t^2 - 2*t + 1))/2 - (16*a*t*(t - 1))/(3*pi)))/b^3 + (pi*(32*t + 3*pi - 6*pi*t + 15*pi*t^2 - 32*t^2))/(3*a*b) + (b*pi^3*(32*t + 3*pi - 6*pi*t + 51*pi*t^2 - 32*t^2))/(18*a^3) + (2*c1*pi*(32*t + 3*pi - 6*pi*t + 15*pi*t^2 - 32*t^2))/(3*a*b) + (2*c2*pi*(32*t + 3*pi - 6*pi*t + 15*pi*t^2 - 32*t^2))/(3*a*b) + (2*c3*pi*(32*t + 3*pi - 6*pi*t + 15*pi*t^2 - 32*t^2))/(3*a*b) + (b*c1*pi^3*(32*t + 3*pi - 6*pi*t + 51*pi*t^2 - 32*t^2))/(12*a^3) + (b*c2*pi^3*(32*t + 3*pi - 6*pi*t + 51*pi*t^2 - 32*t^2))/(15*a^3) + (b*c3*pi^3*(32*t + 3*pi - 6*pi*t + 51*pi*t^2 - 32*t^2))/(18*a^3) + (4*c1^2*pi*(32*t + 3*pi - 6*pi*t + 15*pi*t^2 - 32*t^2))/(9*a*b) + (3*c2^2*pi*(32*t + 3*pi - 6*pi*t + 15*pi*t^2 - 32*t^2))/(5*a*b) + (16*c3^2*pi*(32*t + 3*pi - 6*pi*t + 15*pi*t^2 - 32*t^2))/(21*a*b) + (b*c1^2*pi^3*(32*t + 3*pi - 6*pi*t + 51*pi*t^2 - 32*t^2))/(30*a^3) + (b*c2^2*pi^3*(32*t + 3*pi - 6*pi*t + 51*pi*t^2 - 32*t^2))/(42*a^3) + (b*c3^2*pi^3*(32*t + 3*pi - 6*pi*t + 51*pi*t^2 - 32*t^2))/(54*a^3) + (c1*c2*pi*(32*t + 3*pi - 6*pi*t + 15*pi*t^2 - 32*t^2))/(a*b) + (16*c1*c3*pi*(32*t + 3*pi - 6*pi*t + 15*pi*t^2 - 32*t^2))/(15*a*b) + (4*c2*c3*pi*(32*t + 3*pi - 6*pi*t + 15*pi*t^2 - 32*t^2))/(3*a*b) + (b*c1*c2*pi^3*(32*t + 3*pi - 6*pi*t + 51*pi*t^2 - 32*t^2))/(18*a^3) + (b*c1*c3*pi^3*(32*t + 3*pi - 6*pi*t + 51*pi*t^2 - 32*t^2))/(21*a^3) + (b*c2*c3*pi^3*(32*t + 3*pi - 6*pi*t + 51*pi*t^2 - 32*t^2))/(24*a^3)))/2 + (k_rx*((a*(4*t^2 - 2*t + 1))/2 - (16*a*t*(t - 1))/(3*pi)))/(2*b^2) + (b*k_ry*pi^2*(t - 1)^2*(252*c1^2 + 420*c1*c2 + 360*c1*c3 + 630*c1 + 180*c2^2 + 315*c2*c3 + 504*c2 + 140*c3^2 + 420*c3 + 420))/(1260*a^2) + (a*k_rx*(2*c1 + 3*c2 + 4*c3 + 1)^2*(32*t + 3*pi - 6*pi*t + 12*pi*t^2 - 32*t^2))/(12*b^2*pi) - (b*q_xx*pi*(32*t + 3*pi - 6*pi*t + 15*pi*t^2 - 32*t^2)*(252*c1^2 + 420*c1*c2 + 360*c1*c3 + 630*c1 + 180*c2^2 + 315*c2*c3 + 504*c2 + 140*c3^2 + 420*c3 + 420))/(15120*a)
It is not really clear how to compress the variables and coefficients.

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2018년 10월 2일
The only one that I can think of is the Symbolic Math Toolbox coeffs (link) function. Others, such as simplify (link), and related functions linked to on that page, could also be useful.
  댓글 수: 2
Roy Cornelissen
Roy Cornelissen 2018년 10월 2일
I tried but Matlab return the following:
Error using symengine The indeterminate is invalid.
Star Strider
Star Strider 2018년 10월 2일
Please post the code you used, including the syms declaration.
You would likely have to use the expand function first, to get rid of the fractions, and if the result was a fraction, then use numden, and then simplify and coeffs on both the numerator and denominator.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by