I am not sure I understand the question. Why would you have to write 100+ polynomials? Why not just pass the coefficients as a input parameter to your function, i.e.
function p = test(x,a)
% a = [ a0 a1 a2 a3 a4 ]
p = x.^(0:5)*a(:); % this does 1*a0 + x*a1 + ... + x^4*a4
...
Otherwise, you can also pass a complete vector with input:
a = input('Type the coefficient vector [ a0 a1 a2 a3 a4 ]\n');
Then, minor comments:
1. I would recommend using a finite maximum number of iterations instead of inf.
2. You will probably want to check (abs(x-y) < small_number) instead of x == y since this is a numerical algorithm.
PS: You might want to have a look at polyval if you want to use inbuilt matlab functions with polynomials
