Assuming that the signal
x(t)x(t) size 12{x \( t \) } {} is zero for
t<0t<0 size 12{t"<0"} {} and
t≥Tt≥T size 12{t >= T} {}, we can approximate the CTFT integration in Equation (1) as follows:
∫−∞∞x(t)e−jωtdt=∫0Tx(t)e−jωtdt≈∑n=0N−1x(nτ)e−jωnττ∫−∞∞x(t)e−jωtdt=∫0Tx(t)e−jωtdt≈∑n=0N−1x(nτ)e−jωnττ size 12{ Int cSub { size 8{ - infinity } } cSup { size 8{ infinity } } {x \( t \) e rSup { size 8{ - jωt} } ital "dt"} = Int cSub { size 8{0} } cSup { size 8{T} } {x \( t \) e rSup { size 8{ - jωt} } ital "dt"} approx Sum cSub { size 8{n=0} } cSup { size 8{N - 1} } {x \( nτ \) e rSup { size 8{ - jωnτ} } τ} } {}
(3)where
T=NτT=Nτ size 12{T=Nτ} {} and N is an integer. For sufficiently small
ττ size 12{τ} {}, the above summation provides a close approximation to the CTFT integral. The summation
∑n=0N−1x(nτ)e−jωnτ∑n=0N−1x(nτ)e−jωnτ size 12{ Sum cSub { size 8{n=0} } cSup { size 8{N - 1} } {x \( nτ \) e rSup { size 8{ - jωnτ} } } } {}is widely used in digital signal processing (DSP), and both LabVIEW MathScript and LabVIEW have a built-in function for it called fft. In a .m file, if N samples
x(nτ)x(nτ) size 12{x \( nτ \) } {} are stored in a vector
xx size 12{x} {}, then the function call
>>xw=tau*fft
(x)
calculates
X
ω
(
k
+
1
)
=
τ
∑
n
=
0
N
−
1
x
(
nτ
)
e
−
jω
k
nτ
0
≤
k
≤
N
−
1
≈
X
(
ω
k
)
X
ω
(
k
+
1
)
=
τ
∑
n
=
0
N
−
1
x
(
nτ
)
e
−
jω
k
nτ
0
≤
k
≤
N
−
1
≈
X
(
ω
k
)
alignl { stack {
size 12{X rSub { size 8{ω} } \( k+1 \) =τ Sum cSub {n=0} cSup {N - 1} {x \( nτ \) e rSup { size 8{ - jω rSub { size 6{k} } nτ} } } matrix {
{} # size 12{0 <= k <= N - 1} {}
} } {} #
size 12{~~~~ approx X \( ω rSub { size 8{k} } \) } {}
} } {}
(4)where
ωk={2πkNτ0≤k≤N22πkNτ−2πτN2+1≤k≤N−1ωk={2πkNτ0≤k≤N22πkNτ−2πτN2+1≤k≤N−1 size 12{ω rSub { size 8{k} } = left lbrace matrix {
{ {2πk} over {Nτ} } {} # 0 <= k <= { {N} over {2} } {} ##
{ {2πk} over {Nτ} } - { {2π} over {τ} } {} # { {N} over {2} } +1 <= k <= N - 1{}
} right none } {}
(5)with N assumed to be even. The fft function returns the positive frequency samples before the negative frequency samples. To place the frequency samples in the right order, use the function fftshift as indicated below:
>>xw=fftshift(tau*fft
(x
)
)
Note that
X(ω)X(ω) size 12{X \( ω \) } {} is a vector (actually, a complex vector) of dimension N.
X(ω)X(ω) size 12{X \( ω \) } {} is complex in general despite the fact that
x(t)x(t) size 12{x \( t \) } {} is real-valued. The magnitude of
X(ω)X(ω) size 12{X \( ω \) } {} can be computed using the function abs and the phase of
X(ω)X(ω) size 12{X \( ω \) } {} using the function angle.