Writing a code on user input polynomials

조회 수: 12 (최근 30일)
Violet Lewis
Violet Lewis 2020년 1월 24일
답변: Anmol Dhiman 2020년 1월 27일
Write a code based on user input polynomial that can:
  • Ask the user to input the degree of the polynomial.
  • Based on the inputted degree, ask the user to input the different polynomial coefficients.
  • Generate a range X of values between -100 and 100.
How should this look in matlab?

답변 (1개)

Anmol Dhiman
Anmol Dhiman 2020년 1월 27일
Hi Lewis,
You can refer to below link for implementation of Polynomials in MATLAB.
I am assuming X here is the coefficient values and its range is from -100 to 100.
You can follow the below pseudo code
prompt = 'What is the degree of polynomial ';
degree = input(prompt);
polynomial = [];
for x = 0 to degree
prompt = 'What is the original value? ';
y = input(prompt);
if y >=100 & y>= -100
polynomial(x) =y;
else
print(invalid value)
end

카테고리

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