How to find IDTFT of an array in matlab?

12 vues (au cours des 30 derniers jours)
Palguna Gopireddy
Palguna Gopireddy le 7 Mar 2022
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?

Réponse acceptée

Paul
Paul le 7 Mar 2022
Modifié(e) : Paul le 7 Mar 2022
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 commentaires
Paul
Paul le 12 Mar 2022
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
ans = 1×5
1.0e-13 * 0.1537 0.0877 0.0513 0.2158 0.0916
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))]
ans = 
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.
Palguna Gopireddy
Palguna Gopireddy le 30 Mar 2022
Thanks

Connectez-vous pour commenter.

Plus de réponses (1)

Matt J
Matt J le 7 Mar 2022
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:
h = freqz(___,w) returns the frequency response vector h evaluated at the normalized frequencies supplied in w.
  4 commentaires
Star Strider
Star Strider le 11 Mar 2022
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.
Palguna Gopireddy
Palguna Gopireddy le 12 Mar 2022
So In the documaentation [h,w] = freqz(___,n,'whole'); means we should not give '_' directly, we should put array of numerator and denomenator parameters in that place?

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by