Matlab multiplication of polynomials with syms

In summary, to multiply polynomials in Matlab, you can use the conv function or the * operator. The conv function is recommended for polynomial multiplication. For symbolic polynomials, you can use the * operator after declaring them as symbolic variables using the syms function. The coefficients of a polynomial are represented as a vector in Matlab, with the first element being the coefficient of the highest degree term and the last element being the constant term. Complex coefficients can also be used in polynomial multiplication in Matlab.
  • #1
Ngineer
64
1
Is there anyway around this problem?

syms m,n;
x1 = [0, 1, 4, m];
x2 = [3, n, 9, 27];
conv(x1,x2)
Undefined function 'conv2' for input arguments of type 'sym'
 
Physics news on Phys.org
  • #2
The conv and conv2 functions do not accept symbolic inputs.

I recommend you just generate each symbolic polynomial and then multiply. I don't have MATLAB here but I think it would be something like this:

syms m,n;
x1 = x^2+4x-m;
x2 = 3x^3+nx^2+9x+27;
expand(x1*x2)

http://www.mathworks.com/help/symbolic/expand.html
 

FAQ: Matlab multiplication of polynomials with syms

1. How do I multiply polynomials in Matlab?

To multiply polynomials in Matlab, you can use the conv function. For example, if you have two polynomials p = [1 2 3] and q = [4 5], you can multiply them by typing conv(p, q). This will result in a new polynomial r = [4 13 22 15], which represents the product of p and q.

2. Can I use the * operator to multiply polynomials in Matlab?

Yes, you can use the * operator to multiply polynomials in Matlab. However, this will perform element-wise multiplication, which may not give the desired result for polynomials. It is recommended to use the conv function for polynomial multiplication.

3. How do I multiply two symbolic polynomials in Matlab?

To multiply two symbolic polynomials in Matlab, you first need to declare them as symbolic variables using the syms function. Then, you can use the * operator to multiply the symbolic variables. For example, if you have p = sym('x^2 + 2x + 3') and q = sym('x + 4'), you can multiply them by typing p*q, which will result in a new symbolic polynomial r = x^3 + 6x^2 + 11x + 12.

4. How do I represent the coefficients of a polynomial in Matlab?

In Matlab, the coefficients of a polynomial are represented as a vector, with the first element representing the coefficient of the highest degree term and the last element representing the constant term. For example, the polynomial 2x^3 + 5x^2 - 3x + 1 would be represented as [2 5 -3 1].

5. Can I multiply polynomials with complex coefficients in Matlab?

Yes, you can multiply polynomials with complex coefficients in Matlab. You can represent complex numbers using the i symbol, and perform the multiplication using either the conv function or the * operator. For example, if you have p = [1 2+3i] and q = [4+2i 5], you can multiply them by typing conv(p, q) or p*q, which will result in a new polynomial r = [4+2i 13+22i 21+28i 5+10i].

Similar threads

Replies
6
Views
2K
Replies
4
Views
993
Replies
5
Views
2K
Replies
1
Views
4K
Replies
1
Views
1K
Back
Top