function Y = polyval(P,X)
    N = length(P); 
    [MM,NN] = size(X); Y = P(1)*ones(MM,NN); 
    for i = 2:N
        Y = X.*Y + P(i); 
    end
endfunction
