Matlab program to enter coefficients of a polynomial


Question 1) Write a Matlab program that would allow the user to enter coefficients of a polynomial and make some computations. Selections and data entry would be done by presenting the user with a menu (using menu function) and provide her/him with the following choices:

Enter degree and coefficients of the polynomial

Evaluate polynomial at a user defined point

Display roots of the polynomial

Exit

Other Requirements:

Selecting choice 2 and 3 before entering the degree and coefficients will result in an error message.

The program will terminate only when Exit has been selected

Calculations will be done by functions.

Function polynomial() will ask for the degree and the coefficients of the polynomial and would return the coefficients.

Function polyEval() will accept a parameter, the evaluation point, and returns the value of the polynomial at that point.

Function polyRoots() will accept the coefficients and returns the roots.

Results are displayed with 2 decimal place accuracy.

Help with coefficient entry:

a) store the coefficients of the polynomial that have been entered

b) in a vector.  Return coefficients as a vector called p

c) this vector should be global so that other functions can use it global p;
p=[]; %creates an empty polynomial
degree=input('Please enter the degree of the polynomial: ');
j=degree; %this is used for correct message display below
degree=degree+1;
for i=1:1:degree
fprintf('Please enter the coefficient of power %d ',j);
p(i)=input(' ');
j=j-1;
end

d) note the highest degree coefficient is stored in position 1

e) and the next one is position 2 and so on.

Request for Solution File

Ask an Expert for Answer!!
MATLAB Programming: Matlab program to enter coefficients of a polynomial
Reference No:- TGS04613

Expected delivery within 24 Hours