Using factor on symbolic expression but not always factorizing

8 vues (au cours des 30 derniers jours)
Bill Tubbs
Bill Tubbs le 6 Juil 2020
Commenté : Bill Tubbs le 6 Juil 2020
I'm trying to show both versions of a symbolic equation, one unfactorized and one factorized.
This example works as expected:
>> syms s
>> factor(s^2+2*s+1)
ans =
[ s + 1, s + 1]
However, it does nothing in this case:
>> factor(s^2+4*s+1)
ans =
s^2 + 4*s + 1
Expected:
[ s + 0.2679, s + 3.7321 ]
For reference:
>> roots([1 4 1])
ans =
-3.7321
-0.2679
Is it because the roots are not whole numbers? I.e. Does it only factorize if the factors are simple? Or am I doing something wrong?

Réponse acceptée

madhan ravi
madhan ravi le 6 Juil 2020
factor(s^2+4*s+1,s, 'FactorMode', 'real')

Plus de réponses (0)

Catégories

En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by