Homework #3: problem 1 .Write a MATLAB script which plots and displays in a tabl
ID: 3723544 • Letter: H
Question
Homework #3: problem 1 .Write a MATLAB script which plots and displays in a table individual points entered by a user for a general quintic polynomial: y(x)- axxcx3 + dx2 + ex +f Your program should do the following Read-in the coefficients of the quintic polynomial Read-in 5 individual x values from the user, calculate the corresponding y values, and save all the values in appropriate arrays using a while loop Display the entered values in a table and on a plot. On the same plot, display the actual smooth quintic function from the minimum value to the maximum value entered. ‘ Test your program for a-0.125, b 0, c 15.25, d 13.1, e = 2.6,--1.5 with various x values ranging from a minimum of -3 to a maximum of 3. 15 Homework #3: problem 1 Enter coefficients for a quintic polynonial of the Eorm: y=ax^5 + bx"4 + cx^3 + dx"2 + ex + f Enter a value for a: -0.125 Enter a value for b: 0 Enter a value for e: 15.25 Enter a value for d: 13.1 Enter a value for e: 2.6 Enter a value for f: 1.5 The quintic polynomial you have entered is: (-0.125)%"5 + (0)%"4 + (15.25 3 +113.1)%"2 + (2.6)% + (-1.5) Enter a value for x:-3 Enter a value for x:3 Enter a value for x:1.2 Enter a value for x:-1.8 Enter a value for x: 0.36 1 of 4 y(x)Explanation / Answer
1)
disp('Enter coeficients for a quintic polynomial of the form:')
disp('y=ax^5+bx^4+cx^3+dx^2+ex+f')
a=input('Enter a value of a ')
b=input('Enter a value of b ')
c=input('Enter a value of c ')
d=input('Enter a value of d ')
e=input('Enter a value of e ')
f=input('Enter a value of f ')
disp('The quintic polynomial you have entered is:')
msg = [a,'x^5', b,'x^4',c,'x^3',d,'x^2',e,'x',f];
disp(msg)
arrX=[0 0 0 0 0]
for i = 0:4
arrX[i] = input('Enter a value of X')
end
arrY= a*(arrX.^5)+b*(arrX.^4)+c*(x.^3)+d*(x.^2)+e*x+f
2)
function x=factor()
n=input('Enter a value')
fact=1
if(n<0)
return
end
if(!isinteger(n))
return
end
if(n==0)
fact=1
else
x = n .* factor(n-1) ;
end
factor()
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.