MATLAB: Array made of an infinite number of elements

summation

Hi, the smaller I make t, the more precise the shape of c becomes, but is there a simple way to see what c would look like if t was infinitely small?
t=0.002;
a=(0:t:2)';
b=(-10:0.001:10);
c=sum((sin(bsxfun(@times,b,((pi*2)*a)))),1);
plot(b,c)

Best Answer

Tristan, as it stands, the quantity 'c' will go to infinity as 't' approaches zero. However, you used the phrase "the shape of c", and if you use an appropriate normalizing factor which doesn't involve values of 'b' in computing 'c', then it will in fact converge to a well-defined function of b, that is to say, a well-defined "shape". Demonstrating this involves the useful trigonometric identity:
sin(z) + sin(2*z) + sin(3*z) + ... + sin(n*z) =
sin((n+1)/2*z)*sin(n/2*z)/sin(z/2)
Replace 't' by 2/n and remove the 0 value for 'a' (since that will produce a zero value) and thus redefine 'a':
a = 2/n*(1:n)';
The normalizing factor I recommend is to divide by n in computing 'c'. Then invoking the above trigonometric identity with b*2*pi*t = b*2*pi*2/n playing the role of z above gives:
c = 1/n*sum((sin(bsxfun(@times,b,((pi*2)*a)))),1) =
1/n*sin((n+1)/2*b*2*pi*t).*sin(n/2*b*2*pi*t)./sin(1/2*b*2*pi*t) =
1/n*sin((n+1)/2*b*2*pi*2/n).*sin(n/2*b*2*pi*2/n)./sin(1/2*b*2*pi*2/n) =
1/n*sin((n+1)/n*2*pi*b).*sin(2*pi*b)./sin(2*pi*b/n)
As t approaches zero and therefore n approaches infinity, the quantity 'c' will thus approach
c = sin(2*pi*b).^2./(2*pi*b)
If we substitute x in place of 2*pi*b this becomes
c = sin(x).^2./x
which is a perfectly respectable function of x. This is what 'c' "looks like" for very small t. The above formula also represents a much simpler computation than the summation version.