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?

 Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 12 Mai 2013
Bearbeitet: Andrei Bobrov am 13 Mai 2013

1 Stimme

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 Kommentar

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?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Community Treasure Hunt

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

Start Hunting!

Translated by