How to find coefficient of a polynomial in MatLab? - coeffs -- MatLab

 How to find coefficient of a polynomial in MatLab? - coeffs -- MatLab 


How to find coefficient of a polynomial in MatLab? 
[Ans]
coeffs

[description]
Find all coefficient of a polynomial with symbolic variables.


more details on:

code:

clear
clc
syms x;
c = coeffs(16*x^2 + 19*x + 11)
fprintf("1\n")
syms x y
cx = coeffs(x^3 + 2*x^2*y + 3*x*y^2 + 4*y^3, x)
cy = coeffs(x^3 + 2*x^2*y + 3*x*y^2 + 4*y^3, y)
fprintf("2\n")
syms x y
cxy = coeffs(x^3 + 2*x^2*y + 3*x*y^2 + 4*y^3, [x y])
cyx = coeffs(x^3 + 2*x^2*y + 3*x*y^2 + 4*y^3, [y x])
fprintf("3\n")
syms x
[c,t] = coeffs(16*x^2 + 19*x + 11)
fprintf("4\n")
syms x y
[cx,tx] = coeffs(x^3 + 2*x^2*y + 3*x*y^2 + 4*y^3, x)
[cy,ty] = coeffs(x^3 + 2*x^2*y + 3*x*y^2 + 4*y^3, y)
fprintf("5\n")
syms x y
[cxy, txy] = coeffs(x^3 + 2*x^2*y + 3*x*y^2 + 4*y^3, [x,y])
[cyx, tyx] = coeffs(x^3 + 2*x^2*y + 3*x*y^2 + 4*y^3, [y,x])
fprintf("6\n")
syms x
c = coeffs(3*x^2)
fprintf("7\n")
syms x
c = coeffs(3*x^2, x)
fprintf("8\n")
syms x
c = coeffs(3*x^2, 'All')
fprintf("9\n")

result: 

c =

[11, 19, 16]

1

cx =

[4*y^3, 3*y^2, 2*y, 1]


cy =

[x^3, 2*x^2, 3*x, 4]

2

cxy =

[4, 3, 2, 1]


cyx =

[1, 2, 3, 4]

3

c =

[16, 19, 11]


t =

[x^2, x, 1]

4

cx =

[1, 2*y, 3*y^2, 4*y^3]


tx =

[x^3, x^2, x, 1]


cy =

[4, 3*x, 2*x^2, x^3]


ty =

[y^3, y^2, y, 1]

5

cxy =

[1, 2, 3, 4]


txy =

[x^3, x^2*y, x*y^2, y^3]


cyx =

[4, 3, 2, 1]


tyx =

[y^3, x*y^2, x^2*y, x^3]

6

c =

3

7

c =

3

8

c =

[3, 0, 0]

9



Comments