how to write polynomial code

24 ビュー (過去 30 日間)
Ahmad Dalabeeh
Ahmad Dalabeeh 2017 年 10 月 21 日
回答済み: Krishan Kumar 2020 年 9 月 28 日
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

採用された回答

Birdman
Birdman 2017 年 10 月 21 日
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 件のコメント
Birdman
Birdman 2017 年 10 月 21 日
Thank you Walter, nice to learn.
Ahmad Dalabeeh
Ahmad Dalabeeh 2017 年 10 月 21 日
thank you very much brothers

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

その他の回答 (1 件)

Krishan Kumar
Krishan Kumar 2020 年 9 月 28 日
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

カテゴリ

Help Center および File ExchangePolynomials についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by