how to write polynomial code

조회 수: 23 (최근 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 CenterFile Exchange에서 Polynomials에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by