How to get number of factors after factorizing a symbolic function?

조회 수: 3 (최근 30일)
Bill Tubbs
Bill Tubbs 2020년 7월 6일
댓글: Bill Tubbs 2020년 7월 6일
I'm using factor to factorize a symbolic polynomial.
Works well but when the result is a symbolic vector containing the factors, I'm not sure how to determine how many factors it contains. I tried using size but I get some inconsistent results:
>> G(s) = s^2 + 3*s + 2;
>> F = factor(G, s)
F(s) =
[ s + 2, s + 1]
>> size(F)
ans =
1 1
>> F = factor(G(s), s)
F =
[ s + 2, s + 1]
>> size(F)
ans =
1 2
>>
Note, the size is different in the second example. The only difference is that I used factor(G(s), s) rather than factor(G, s). What is the difference and why does the result (F) look the same but the size is not the same?
  댓글 수: 2
Bill Tubbs
Bill Tubbs 2020년 7월 6일
편집: Bill Tubbs 2020년 7월 6일
Ah, I think I know what is going on. class(G) is 'symfun' whereas class(G(s)) is 'sym'.
I guess I need to decide whether to pass the function itself or the symbolic expression it returns given s.
If I only pass the function (G), how would I determine how many factors it has? I.e. the dimension of the symbolic function.
madhan ravi
madhan ravi 2020년 7월 6일
Now you don’t see Star’s answer below.

댓글을 달려면 로그인하십시오.

채택된 답변

madhan ravi
madhan ravi 2020년 7월 6일
numel(formula(F)) % will avoid confusions ;)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by