I may not know the purpose of the function, but I can answer your questions...
This line generates 100 equally spaced points between 0 and x. If you change it to linspace(0, x, N), this will generate N equally spaced points between 0 and x.
The loop here is needed because uy and xx are vectors, but the function sing is written in a way that it will only do what you want if the input is a scalar. It isn't actually needed, the code can be written without the loop, which will speed things up a little...
xx = linspace(0,x);
uy = (-5/6).*(sing(xx,0,4)-sing(xx,5,4))...
+ (15/6).*sing(xx,8,3) + 75*sing(xx,7,2)...
+ (57/6).*xx.^3 - 238.25.*xx;
function s = sing(xxx,a,n)
Num = length(xxx);
s(xxx>a) = (xxx(xxx>a) - a).^n;
As for why the writer changes from x, to xx, to, xxx, well that is anybody's guess. He will have been trying to use distinct variables for the different parts of the code. It is always better to try and name variables according to what they are.
Hope this helps!