How to simplify a common factor in a symbolic equation
Ältere Kommentare anzeigen
My code is as follows
syms I_1 phi_1_d2 R_1 f_g mu_1 I_2 phi_2_d2 R_2 mu_2
eq_1= mu_1== I_1 * phi_1_d2 + R_1 * f_g;
eq_2= mu_2== I_2 * phi_2_d2 - R_2 * f_g;
eq_1= expand(eq_1 * (I_2 * R_1));
eq_2= expand(eq_2 * (I_1 * R_2));
eq_3= eq_1 - eq_2;
eq_3= collect(eq_3, [I_1, I_2]);
eq_3= collect(eq_3, f_g);
eq_4= eq_3 / ((I_2 * (R_1 ^2)) + (I_1 * (R_2 ^2)));
eq_4= collect(eq_4, f_g)
With the output being
eq_4 =
(R_1*mu_1*I_2 + (-R_2*mu_2)*I_1)/(I_2*R_1^2 + I_1*R_2^2) == ((I_2*R_1^2 + I_1*R_2^2)/(I_2*R_1^2 + I_1*R_2^2))*f_g + (I_1*I_2*(R_1*phi_1_d2 - R_2*phi_2_d2))/(I_2*R_1^2 + I_1*R_2^2)
This is correct as far as I can tell, however I'm unsure how to make matlab recognise that the coefficient for the f_g term is 1
Any help would be appreciated, I am new to MATLAB and unfamiliar with the symbolic toolkit
2 Kommentare
John D'Errico
am 18 Mai 2020
Bearbeitet: John D'Errico
am 18 Mai 2020
The coef of the f_g term, meaning this expression from eq_4?
((I_2*R_1^2 + I_1*R_2^2)/(I_2*R_1^2 + I_1*R_2^2))
So now you wish to (programmatically) extract that coefficient, and set it to 1 as a new equation? I'll admit to being a bit lazy. I'd probably just use cut and paste, a far faster alternative to reading the help for the function coeffs. ;-)
Ok, I think you are saying that you see this expression is just the ratio of two numbers, which happen to be the same, and you are asking how to force MATLAB to recognize that X/X is just 1? Sometimes getting a computer to recognize what you see as obvious is harder than just using pencil and paper. But is that your question?
Kieran Corrigan
am 18 Mai 2020
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Assumptions finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!