% % my first matlab function % % save as: "wpoly.m" % % to run: type "wpoly(x,N,a)" at the matlab prompt, % where x,N,a are pre-defined, or just "wpoly(pi,2,0)" % % try "help function" % % it also works for vector-valued x! % %- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - function [out] = wpoly(x,N,a) y = ones(size(x)); N = floor(abs(N)); for j = 1:N y = y.*(x-j); end out = y - a*N*(N+1)/2*x.^(N-1); % % !!! NOTE: you can use this within wilk.m !!! %