I have the following function:
function [ res ] = F( n )
t = 1.5;
res = 0;
if n <= 0
return;
end
for i = 0:n-1
res = res + power(-1,i)*power(t,2*i+1)/((2*i+1)*factorial(i));
end
end
I'm trying to pass an array to it so that I could see its output for every point in the array
F([2,3,4])
For some reason it refuses to act on the whole array, only giving me the output for the first member. Why is that?
EDIT: If I change
res = 0;
at the beginning to
res = 0 + n;
res = res - n;
It does work for the whole array.