- 'simplify': https://www.mathworks.com/help/symbolic/simplify.html
- 'numden': https://www.mathworks.com/help/symbolic/sym.numden.html
- 'diff': https://www.mathworks.com/help/symbolic/diff.html
How can I rearrange an equation to multiple varriables?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Brahmadev
am 16 Feb. 2024
Bearbeitet: Brahmadev
am 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
Also, you can refer to the following documentation for more information:
Hope this helps in resolving your query!
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!