how to write polynomial code
25 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ahmad Dalabeeh
le 21 Oct 2017
Réponse apportée : Krishan Kumar
le 28 Sep 2020
how to write a code that:
- Reads any polynomial P
- Finds its roots.
- Shows the degree of the polynomial.
- Calculates P^3 - Plots the polynomials P and P^3 on a suitable domain specified by the user
0 commentaires
Réponse acceptée
Birdman
le 21 Oct 2017
syms x
p(x)=x^2+2*x-3;%as an example
Coeff=coeffs(p(x))';
Coeff=wrev(Coeff);
Roots=roots(Coeff);%roots
Degree=length(Coeff)-1;%degrees
disp(p^3)%calculates p^3
x=0:0.1:1;
plot(x,p(x));grid on;%plots
3 commentaires
Plus de réponses (1)
Krishan Kumar
le 28 Sep 2020
syms x p(x)=x^2+2*x-3;%as an example Coeff=coeffs(p(x))'; Coeff=wrev(Coeff); Roots=roots(Coeff);%roots Degree=length(Coeff)-1;%degrees disp(p^3)%calculates p^3 x=0:0.1:1; plot(x,p(x));grid on;%plots
0 commentaires
Voir également
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!