4.5. Polynomial Addition and Subtraction

Two polynomials can be added by using the arithmetic operator plus ‘+’, i.e., if two polynomials x and y are to be added, the following command can be used:

z = x + y

The corresponding elements of the row vectors x and y are added and resultant is z vector.

Similarly, subtraction is done by using operator minus ‘−’ and the syntax is given as follows:

z = x - y

It subtracts each element of y from the corresponding element of x and the resultant is stored in z.

In both the above operations, the dimension of both polynomial vectors must be the same.

Example 4.4.

Add the two polynomials, a = (s2 + 2s + 1) and b = (s3 + s + 5).

Solution:

These polynomials are represented by the two vectors:

a = [0 1 2 1]; ...

Get MATLAB® and Its Applications in Engineering: [Based on MATLAB 7.5 (R2007b)] now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.