Clear Filters
Clear Filters

Replacing variables with dummy variables

2 views (last 30 days)
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 Comments
Adam
Adam on 2 Oct 2018
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 on 2 Oct 2018
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.

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 2 Oct 2018
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 Comments
Roy Cornelissen
Roy Cornelissen on 2 Oct 2018
I tried but Matlab return the following:
Error using symengine The indeterminate is invalid.
Star Strider
Star Strider on 2 Oct 2018
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.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!