Divide two polynomials using MATLAB

前端 未结 2 771
误落风尘
误落风尘 2021-01-23 03:41

I want to divide p(x) by q(x) given that:

p(x)=-5x^4+3x^2-6x
q(x)=x^2+1

I tried:

p=inline(\'-5*(x^4)+         


        
相关标签:
2条回答
  • 2021-01-23 03:54

    r = sym(p) \ sym(q) would do the trick. The result would be a symbolic function, of course. To convert that to inline, s = inline(r).

    Edit: As for the "WHY": you cannot divide two inline functions. Instead, they must first be converted to their symbolic representation.

    0 讨论(0)
  • 2021-01-23 04:08

    Inline functions are just matlab expressions that it will evaluate. It has no idea whether they are polynomials or not.

    You want this:

    p = [-5 0 3 -6 0];
    q = [2 0 1];
    
    [quotient remainder] = deconv(p, q)
    

    No need for Symbolic Math Toolbox here.

    0 讨论(0)
提交回复
热议问题