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?

 採用された回答

Andrei Bobrov
Andrei Bobrov 2013 年 5 月 12 日
編集済み: Andrei Bobrov 2013 年 5 月 13 日

1 投票

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 件のコメント

mintug
mintug 2013 年 5 月 17 日
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?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangePolynomials についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by