MATLAB: Function instead of polyval

homeworkmatlab function

Is there a Matlab built in function that can be used instead of a polyval function. Or any few lines can work similarly like the polyval function because i dont want to use the polyval function.

Best Answer

fnotpolyval = @(p,x)sum(bsxfun(@(x,p)p*x.^(numel(p):-1:1),p',x))
or
fnotpolyval = @(p,x)sum(x'*p,2)'