Professional Documents
Culture Documents
2 Numeric, Cell, and Structure Arrays 2 Numeric, Cell, and Structure Arrays
2.10 Polynomial Operations Using Arrays 2.10 Polynomial Operations Using Arrays
f x a1 x n a2 x n1 a3 x n2 ... an1 x 2 an x an1 To find polynomial roots → roots (a)
(a): array contaning the polynomialcoefficients.
f(x): the function of x, degree(order): n To compute the coefficients of the polynomial whose roots are
ai (i=1,1,….,n+1): polynomial’s coefficients specified by the array (a)
→ using row vector to describe a polynomial → poly(a)
→ f(x) can be described as follows:
a , a , a ,..., a
1 2 3 n 1 , an, an1
Ex: [4,-8,7,-5] represents for:
4 x3 8x 2 7 x 5
7 September 2021 Introduction to Computing – Matlab Application NV Binh 26 7 September 2021 Introduction to Computing – Matlab Application NV Binh 27
2 Numeric, Cell, and Structure Arrays 2 Numeric, Cell, and Structure Arrays
2.10 Polynomial Operations Using Arrays 2.10 Polynomial Operations Using Arrays
Given 2 polynomials
Given 2 polynomials
f x 9 x 3 5 x 2 3x 7 f 9,5,3,7
f x 9 x 3 5 x 2 3x 7 f 9,5,3,7
g ( x) 6 x 2 x 2 g 6,1,2
g ( x) 6 x 2 x 2 g 6,1,2
7 September 2021 Introduction to Computing – Matlab Application NV Binh 28 7 September 2021 Introduction to Computing – Matlab Application NV Binh 29
2 Numeric, Cell, and Structure Arrays 2 Numeric, Cell, and Structure Arrays
2.10 Polynomial Operations Using Arrays 2.10 Polynomial Operations Using Arrays
Plotting Polynomials Plotting Polynomials
Polyval(a,x): evaluates a polynomial at specified values of its Polyval(a,x): evaluates a polynomial at specified values of its
independent variable x, which can be a matrix or a vector. independent variable x, which can be a matrix or a vector.
Ex: Ex:
Find the value of f(x) at x=0,2,4,…,10 Find the value of f(x) at x=0,2,4,…,10
7 September 2021 Introduction to Computing – Matlab Application NV Binh 30 7 September 2021 Introduction to Computing – Matlab Application NV Binh 31
2 Numeric, Cell, and Structure Arrays
2.10 Polynomial Operations Using Arrays
Plotting Polynomials
f x 9 x 3 5 x 2 3x 7