## Polynomial plotting 
## Author: meral <meral@DESKTOP-7JLIIHR>
## Created: 2021-08-22
## e polynomial coefficients(poly_least)
## x,y original data
## x0,xn curve fitted data limits
## n number of urve fitted data

function retval = poly_plot (x,y,e,x0,xn,n,xlabel1,ylabel1,plabel1)
switch nargin
        case 6
           xlabel1='x';
           ylabel1='y';
           plabel1='f(x)';
        case 3
            xlabel1='x';
            ylabel1='y';
            plabel1='f(x)';
            n=length(x);
            x0=min(x);
            xn=max(x);
        case 2
            n1=input("degree of polynomial?")
            e=poly_least(x,y,n1)
            xlabel1='x';
            ylabel1='y';
            plabel1='f(x)';
            n=length(x);
            x0=min(x);
            xn=max(x);     
end  
x1=zeros(n);
y1=zeros(n);
xmax=max(x);
xmin=min(x);
dx=(xmax-xmin)/(n-1);
for i=1:n
    x1(i)=xmin+(i-1.0)*dx;
    xx=x1(i);
    y1(i)=poly_func(e,xx);
end # for i
plot(x,y,'o',x1,y1);
title(plabel1);
xlabel(xlabel1);
ylabel(ylabel1);
endfunction
