# How can I rearrange an equation to multiple varriables?

1 visualizzazione (ultimi 30 giorni)
Stan Smit il 17 Nov 2021
Modificato: Brahmadev il 16 Feb 2024
Hi,
I have an equation (full of unkowns) whom I want to rearrange into the form:
e*(....) + f*(....)+g*(....) = (....)
I want to rewrite it to this form so I can implement it in an adaptive Excel document, where it will be used in a Matrix (where the other variables (except, e, f, g) will me known.
Is there a way to do this with Matlab?
The complete formula is:
(a*(YBL*e - YBR*e - YAL*f + YBR*f + YAL*g - YBL*g))/(XB*YBL*e - XB*YBR*e - XB*YAL*f + XA*YBR*f - XA*YBL*g + XB*YAL*g) + (c*(XA - XB)*(YBL - YBR))/(XB*YBL*e - XB*YBR*e - XB*YAL*f + XA*YBR*f - XA*YBL*g + XB*YAL*g) + (b*(XA - XB)*(f - g))/(XB*YBL*e - XB*YBR*e - XB*YAL*f + XA*YBR*f - XA*YBL*g + XB*YAL*g)=1
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposte (1)

Brahmadev il 16 Feb 2024
Modificato: Brahmadev il 16 Feb 2024
For manipulating equations that you have mentioned above, the Symbolic Math Toolbox can be very useful. You can use the 'diff' function to find the partial derivative with respect to 'e', 'f' and 'g' and find the coefficients after simplifying the code using the 'simplify' function.
% Defining variables as symbolic
syms a b c d e f g YAL YBL XA XB YBR
eqn = (a*(YBL*e - YBR*e - YAL*f + YBR*f + YAL*g - YBL*g))/(XB*YBL*e - XB*YBR*e - XB*YAL*f + XA*YBR*f - XA*YBL*g + XB*YAL*g) + (c*(XA - XB)*(YBL - YBR))/(XB*YBL*e - XB*YBR*e - XB*YAL*f + XA*YBR*f - XA*YBL*g + XB*YAL*g) + (b*(XA - XB)*(f - g))/(XB*YBL*e - XB*YBR*e - XB*YAL*f + XA*YBR*f - XA*YBL*g + XB*YAL*g) == 1;
% Getting the numerator and denominator for RHS and LHS
[LN, LD] = numden(lhs(eqn));
[RN, RD] = numden(rhs(eqn));
% Simplifying the equation and creating a new equation with denominator as
% 1
neweqn1 = simplify(LN * RD) - simplify(RN * LD) == 0;
% Finding the co-efficients of e, f and g
v_e = diff(neweqn1, e);
v_f = diff(neweqn1, f);
v_g = diff(neweqn1, g);
% Finding the constant expression to create final form of the equation
constant_expr = simplify(lhs(neweqn1) - lhs(v_e*e+v_f*f+v_g*g));
% Equation with rearranged coefficients
finaleqn = lhs(v_e*e+v_f*f+v_g*g) == constant_expr
finaleqn =
Also, you can refer to the following documentation for more information:
Hope this helps in resolving your query!
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

R2017a

### Community Treasure Hunt

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

Start Hunting!

Translated by