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

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 Exchange에서 Polynomials에 대해 자세히 알아보기

질문:

2013년 5월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by