% evaluation of polynominal function at a point
% e.g., y = -x^2+x+2 at point x = 4.

clear, clc

% coeffcients of polynominal:
coef = [-1,1,2]

% function value at point 4 
y = polyval(coef,4)

display('value of y = -x^2+x+2 at point x = 4 is')
y
pause

% evaluation of polynominal function with an interval
% e.g., y = -x^2+x+2 within [-2,2]

% generate a vector to represent interval [-2,2] with step 0.1
x = -2:.1:2

% function values as a vector y
y = polyval(coef,x);

% plotthe function within the defined interval 
plot(x,y,'r.'); grid
title('y=-x^2+x+2')

