array made of an infinite number of elements

조회 수: 1 (최근 30일)
Tristan
Tristan 2013년 12월 4일
편집: Roger Stafford 2013년 12월 7일
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)

채택된 답변

Roger Stafford
Roger Stafford 2013년 12월 5일
편집: Roger Stafford 2013년 12월 5일
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.
  댓글 수: 2
Tristan
Tristan 2013년 12월 7일
Thanks! What would happen if I added an amplitude function? for example:
Amp=sin(a*(pi/2));
c=sum((bsxfun(@times,Amp,sin(bsxfun(@times,b,((pi*2)*a))))),1);
is there an easier way to find c?
Roger Stafford
Roger Stafford 2013년 12월 7일
편집: Roger Stafford 2013년 12월 7일
Yes, if you normalize in the same way as before by dividing by n, this expression will also converge to a limit for each value of b. Showing that depends on a similar trigonometric identity:
cos(z) + cos(2*z) + cos(3*z) + ... + cos(n*z) =
cos((n+1)/2*z)*sin(n/2*z)/sin(z/2)
Remembering that a = 2/n*(1:n), and also making use of the identity
sin(A)*sin(B) = 1/2*(cos(A-B)-cos(A+B))
gives
c = 1/n*sum(sin(pi/2*a).*sin(2*pi*b*a))
= 1/(2*n)*sum(cos((4*b-1)/2*pi*a)-cos((4*b+1)/2*pi*a))
= 1/(2*n)* ...
(cos((n+1)/n*pi/2*(4*b-1))*sin(pi/2*(4*b-1))/sin(pi/2*(4*b-1)/n) ...
-cos((n+1)/n*pi/2*(4*b+1))*sin(pi/2*(4*b+1))/sin(pi/2*(4*b+1)/n))
Of course this last expression uses a larger amount of matlab code space but the summation is gone, so for large n there are far fewer operations, and moreover this form allows us to take the limit as n approaches infinity. This results in a limiting c value of
c = 1/2*(sin((4*b-1)*pi)/((4*b-1)*pi)-sin((4*b+1)*pi)/((4*b+1)*pi))
which as you see is a perfectly respectable function of b - it is the difference between two sinc functions shifted in phase with respect to one another.
Added comment - (Corrected, I previously multiplied instead of divided by pi.)
The limiting c can also be expressed as:
c = sin(4*pi*b)/pi/(1-4*b)/(1+4*b)

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Wayne King
Wayne King 2013년 12월 4일
편집: Wayne King 2013년 12월 4일
Do you have the Symbolic Toolbox, if so you can determine limits
syms x
limit(sin(x)/x)
to find the limit at a particular value,
syms x
limit(exp(-x^2),inf)
That isn't exactly what you're asking, but other than simply making your increment smaller that's all you can do.
You can also plot symbolically:
syms x;
ezplot(sin(x)/x,[-10 10])
  댓글 수: 1
Walter Roberson
Walter Roberson 2013년 12월 4일
And to answer the implied other half of the question: there is no way to handle infinity numerically.
For example for sin(x) you can poke around numerically near the upper limits of numeric precision of MATLAB, and you would deduce some particular value for the limit, but in fact limit sin(x) is undefined rather than any particular number.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MuPAD에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by