Using factor on symbolic expression but not always factorizing

9 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

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

Più risposte (0)

Prodotti


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by