Substitute a polynomial into another polynomial??

I want to subsitute x^2 (coefficients =[1 0 0]) into x^3+x+1 [1 0 1 1],
so I will obtain x^6+x^2+1 [1 0 0 0 1 0 1]
How can I do that?

 Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 12 de Mayo de 2013
Editada: Andrei Bobrov el 13 de Mayo de 2013
p1 = [1 0 1 1];
p2 = [1 0 0];
n2 = find(fliplr(p2(1:end-1)));
n1 = find(fliplr(p1(1:end-1)));
n = n1*n2;
pout(n) = 1;
out = fliplr([p1(end) pout]);
or without fliplr
n2 = find(p2(end-1:-1:1));
n1 = find(p1(end-1:-1:1));
n = n1*n2;
pout(n) = 1;
out = [pout(end:-1:1), p1(end)];

1 comentario

Hi, I notice that it does not work for every equation such that
x^3 [1 0 0 0] ------> x^4 + x^2 + x + 1 [1 0 1 1 1]
It gives -------> x^12 + x^6 + x^4 + x^3 + x^2 + 1
Do you have a generalized method? At least could you explain the logic of your code?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Polynomials en Centro de ayuda y File Exchange.

Preguntada:

el 12 de Mayo de 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by