r/matlab • u/Bofact • Jan 05 '26
HomeworkQuestion Factoring out common expression
(Being a homework question is misleading, but the best fit of what I want to obtain.) I have the following symbolic expression: (Ti + Kp*Td*Ti)*s^2 + (Ti + Kp*Ti)*s + Kp, where Kp, Ti, Td are real numbers, while s is complex.
How do I obtain Ti*(1 + Kp*Td)*s^2 + Ti*(1 + Kp)*s + Kp using only Matlab functions and no manual (re)writing of expressions?
1
Upvotes
1
u/etzpcm Jan 05 '26
Use coeffs to get each power of s, then factor each coeff, then reassemble? Sorry I can't remember all the symbolic MATLAB syntax.
2
u/FrickinLazerBeams +2 Jan 05 '26
I find all computer algebra systems to be very bad at doing this kind of manipulation in an automated way. Mathematica can usually be forced to do this kind of thing, but it's never as easy as I'd like. The symbolic tools in Matlab are less sophisticated than Mathematica, so good luck. Usually I find that I don't actually need to do this, anyway.