Problem with Matlab example

This is my problem:

Create a function for this:

http://img108.imageshack.us/img108/446/functionpf4.jpg

n= 1, 2, 3, 5, and 10 each time.

x= -pi to pi (with 100 values)

I made this:

SERIE.M
function f=serie(x,n)
f=1;
for i=1:n
f=f+((-1)^n * x.^(2n)) / (prod([1:2n]));
end

TP.M
x=linspace(-pi,pi,100);
n=[1, 2, 3, 5, 10];
fcos=cos(x);
for i=1:length(n)
n(i)
pause
y(i)=serie(x,n(i))
pause
errora(i)=abs(fcos-y(i))
pause
errorr(i)=errora(i)./fcos
pause
end
end

When I run that, an error appear:
??? In an assignment A(I) = B, the number of elements in B and
I must be the same.

Error in ==> TP.M
On line 7 ==> y(i)=serie(x,n(i))

Thanks if you can help me.
I use MATLAB 6.5 r13