How to find IDTFT of an array in matlab?
17 次查看(过去 30 天)
显示 更早的评论
We have freqz function to find the DTFT of an array which gives the 512 samples (0 to pi) in frequency domain.
For example freqz used on rectangular window of length 45, which gave 512 complex points array in frequency domain. Now I want to reverse this operation to get the rectangular window of 45 points in time domain.
Does matlab has any function for IDTFT or atleast there is a way we can acheive this with or without MATLAB.
Also how to get (0 to 2pi) points instead if (0 to pi) points using freqz?
0 个评论
采纳的回答
Paul
2022-3-7
编辑:Paul
2022-3-7
As @Matt J noted, you can specify the frequency vector that freqz should use to cover whatever frequencies are desired. Or freqz accepts a parameter 'whole' that makes it use a frequency vector all the way around the unit circle (except the last point is not 2*pi, it's 2*pi - dw)
As for inverting the DTFT, I don't believe that Matlab has a built-in function. But the iDTFT is defined in terms of an integral which can be evaluted numerically (or symbolically I suppose). Assuming you already have h and w, the iDTFT integrand can potentially be computed by interpolation of h.
Here is a link that may be helpful. Based on the Question, I think you want the second version in Eq. 4.
If you try to code it up and have some problems, feel free to post a follow-up comment showing what you've done and what the problem is.
3 个评论
Paul
2022-3-12
I think the problem in the code is that rfrq has 511 elements ( maybe it should have 512?) and exp(j*w*n) has only 45 elements. So those can't be elementwise multiplied. But even if the dimensions are corrected, the code still has other problems/
However, if you want to use sympolic math for finite duration sequences. there is no need to use freqz() at all, because we know the equation for the DTFT
Let's attack the problem for a simple sequence that maybe can be adapted as needed.
Instead of rectwin(45), let the sequence r(n) be defined as:
r(n) = n for 0 <= n <= 10, and 0 otherwise
rvals = 1:10; % ensure r is a row vector
Because rvals has only 10 non-nonzero elements corresponding to 1 <= n <= 10, its DTFT is simply
syms w real
R(w) = sum(rvals.*exp(-1j*(1:10)*w));
Let's compare R(w) to freqz() for some random frequencies just to make sure
rng(100)
wvals = rand(1,5)*2*pi;
abs(double(R(wvals)-freqz([0 rvals],1,wvals))) % pad with leading zero because rvals(1) corresponds to n = 1
Not exactly zero, but close enough in floating point.
Now that we have R(w) we can use the iDTFT integral to recover r(n)
syms n integer
r(n) = int(R(w)*exp(1j*w*n),w,0,2*sym(pi),'hold',true)/2/sym(pi);
Evaluate r(n) at some values of n
[-5:15; release(r(-5:15))]
which looks like the expected result, i.e., n for 1 <= n <= 9 and 0 otherwise.
If use of freqz() is required, then symbolic math is probably not the way to go.
更多回答(1 个)
Matt J
2022-3-7
Does matlab has any function for IDTFT
It doesn't because your frequency domain data is not really continuous, you're really looking for the IFFT, which MATLAB does have a function for (namely ifft() ).
Also how to get (0 to 2pi) points instead if (0 to pi) points using freqz?
From the doc:
4 个评论
Star Strider
2022-3-11
The first argument to freqz must be one or more filter parameters, such as the numerator and denominator of a transfer function, or a second-order-section matrix.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spectral Estimation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!