power of polynomial (without symbolic calculation)

11 vues (au cours des 30 derniers jours)
Kamuran
Kamuran le 28 Mai 2015
Commenté : Star Strider le 28 Mai 2015
Hello, Is there away to get nth power of polynomial without using symbolic calculation? For example f(x)=x^2+1 and I want g(x)=(x^2+1)^3 => x^6 + 3*x^4 + 3*x^2 + 1
so without symbolic variables => f=[2 1] => g=[1 0 3 3 0 1]
Thanks
Kamuran

Réponse acceptée

Star Strider
Star Strider le 28 Mai 2015
Your ‘g’ is incorrect.
This works:
pn = [1 0 1]; % Polynomial
res = 1; % Result Variable
pwr = 3; % Power
for k1 = 1:pwr
res = conv(res, pn);
end
Result = res
  2 commentaires
Kamuran
Kamuran le 28 Mai 2015
Great Thanks
Star Strider
Star Strider le 28 Mai 2015
My pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Polynomials dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by