1. 程式人生 > >【 MATLAB 】訊號處理工具箱之 ifft 簡介及案例分析

【 MATLAB 】訊號處理工具箱之 ifft 簡介及案例分析

這篇博文和上篇博文對應:【 MATLAB 】訊號處理工具箱之fft簡介及案例分析

目錄

ifft

Syntax

Description

案例分析

Inverse Transform of Vector

Padded Inverse Transform of Matrix

Conjugate Symmetric Vector


ifft

Inverse fast Fourier transform



Syntax

X = ifft(Y)

X = ifft(Y,n)

X = ifft(Y,n,dim)

X = ifft(___,symflag)



Description

X = ifft(Y)

X = ifft(Y) computes the inverse discrete Fourier transform of Y using a fast Fourier transform algorithm. X is the same size as Y.

  • If Y is a vector, then ifft(Y) returns the inverse transform of the vector.

  • If Y is a matrix, then ifft(Y) returns the inverse transform of each column of the matrix.

  • If Y is a multidimensional array, then ifft(Y) treats the values along the first dimension whose size does not equal 1 as vectors and returns the inverse transform of each vector.

本想翻譯一下的,但是手冊裡面的英文描述的太清晰了,單詞也很簡單,所以就這樣直接看吧。


X = ifft(Y,n) returns the n-point inverse Fourier transform of Y by padding Y with trailing zeros to length n.

X = ifft(Y,n,dim) returns the inverse Fourier transform along the dimension dim. For example, if Y is a matrix, then ifft(Y,n,2) returns the n-point inverse transform of each row.

X = ifft(Y,n,dim)沿維度dim返回逆傅立葉變換。 例如,如果Y是矩陣,則ifft(Y,n,2)返回每行的n點逆變換。

X = ifft(___,symflag) specifies the symmetry of Y. For example, ifft(Y,'symmetric') treats Y as conjugate symmetric.

X = ifft(___,symflag)指定Y的對稱性。例如,ifft(Y,'symmetric')將Y視為共軛對稱。



案例分析

Inverse Transform of Vector

% The Fourier transform and its inverse convert between data sampled in time and space and data sampled in frequency.
% 
% Create a vector and compute its Fourier transform.

X = [1 2 3 4 5];
Y = fft(X)
% Y = 1×5 complex
% 
%   15.0000 + 0.0000i  -2.5000 + 3.4410i  -2.5000 + 0.8123i  -2.5000 - 0.8123i  -2.5000 - 3.4410i ⋯
% 
% Compute the inverse transform of Y, which is the same as the original vector X.

ifft(Y)
% ans = 1×5
% 
%      1     2     3     4     5

結果如下:

 ifft_vector

Y =

  1 至 4 列

  15.0000 + 0.0000i  -2.5000 + 3.4410i  -2.5000 + 0.8123i  -2.5000 - 0.8123i

  5 列

  -2.5000 - 3.4410i


ans =

     1     2     3     4     5


Padded Inverse Transform of Matrix

clc
clear
close all
% The ifft function allows you to control the size of the transform.
% 
% Create a random 3-by-5 matrix and compute the 8-point inverse Fourier transform of each row.
% Each row of the result has length 8.

Y = rand(3,5)
n = 8;
X = ifft(Y,n,2)
size(X)

結果如下:

Y =

    0.8147    0.9134    0.2785    0.9649    0.9572
    0.9058    0.6324    0.5469    0.1576    0.4854
    0.1270    0.0975    0.9575    0.9706    0.8003


X =

  1 至 4 列

   0.4911 + 0.0000i  -0.0224 + 0.2008i   0.1867 - 0.0064i  -0.0133 + 0.1312i
   0.3410 + 0.0000i   0.0945 + 0.1382i   0.1055 + 0.0593i   0.0106 + 0.0015i
   0.3691 + 0.0000i  -0.1613 + 0.2141i  -0.0038 - 0.1091i  -0.0070 - 0.0253i

  5 至 8 列

   0.0215 + 0.0000i  -0.0133 - 0.1312i   0.1867 + 0.0064i  -0.0224 - 0.2008i
   0.1435 + 0.0000i   0.0106 - 0.0015i   0.1055 - 0.0593i   0.0945 - 0.1382i
   0.1021 + 0.0000i  -0.0070 + 0.0253i  -0.0038 + 0.1091i  -0.1613 - 0.2141i


ans =

     3     8

上面的程式是計算矩陣每一行的8點ifft,故結果是每一行的ifft有8個元素,而計算矩陣 Y 每一行的 ifft,關鍵語句為:

X = ifft(Y,n,2),裡面的2,如果去掉2,則是對矩陣Y的每一列計算ifft,測試如下:

clc
clear
close all
% The ifft function allows you to control the size of the transform.
% 
% Create a random 3-by-5 matrix and compute the 8-point inverse Fourier transform of each row.
% Each row of the result has length 8.

Y = rand(3,5)
n = 8;
X = ifft(Y,n)
size(X)

 

Y =

    0.1419    0.7922    0.0357    0.6787    0.3922
    0.4218    0.9595    0.8491    0.7577    0.6555
    0.9157    0.6557    0.9340    0.7431    0.1712


X =

  1 至 4 列

   0.1849 + 0.0000i   0.3009 + 0.0000i   0.2274 + 0.0000i   0.2725 + 0.0000i
   0.0550 + 0.1517i   0.1838 + 0.1668i   0.0795 + 0.1918i   0.1518 + 0.1599i
  -0.0967 + 0.0527i   0.0171 + 0.1199i  -0.1123 + 0.1061i  -0.0080 + 0.0947i
  -0.0195 - 0.0772i   0.0142 + 0.0028i  -0.0706 - 0.0417i   0.0179 - 0.0259i
   0.0795 + 0.0000i   0.0611 + 0.0000i   0.0151 + 0.0000i   0.0830 + 0.0000i
  -0.0195 + 0.0772i   0.0142 - 0.0028i  -0.0706 + 0.0417i   0.0179 + 0.0259i
  -0.0967 - 0.0527i   0.0171 - 0.1199i  -0.1123 - 0.1061i  -0.0080 - 0.0947i
   0.0550 - 0.1517i   0.1838 - 0.1668i   0.0795 - 0.1918i   0.1518 - 0.1599i

  5 列

   0.1524 + 0.0000i
   0.1070 + 0.0793i
   0.0276 + 0.0819i
  -0.0089 + 0.0365i
  -0.0115 + 0.0000i
  -0.0089 - 0.0365i
   0.0276 - 0.0819i
   0.1070 - 0.0793i


ans =

     8     5
 


Conjugate Symmetric Vector

For nearly conjugate symmetric vectors, you can compute the inverse Fourier transform faster by specifying the 'symmetric' option, 
which also ensures that the output is real. Nearly conjugate symmetric data can arise when computations introduce round-off error.

Create a vector Y that is nearly conjugate symmetric and compute its inverse Fourier transform. 
Then, compute the inverse transform specifying the 'symmetric' option, which eliminates the nearly 0 imaginary parts.

對於近似共軛對稱向量,您可以通過指定“symmetric”選項來更快地計算逆傅立葉變換,這也確保了輸出是真實的。 當計算引入舍入誤差時,可能出現幾乎共軛的對稱資料。

建立幾乎共軛對稱的向量Y並計算其逆傅立葉變換。然後,計算指定'對稱'選項的逆變換,它消除了近0虛部。

clc
clear
close all
% For nearly conjugate symmetric vectors, you can compute the inverse Fourier transform faster by specifying the 'symmetric' option, 
% which also ensures that the output is real. Nearly conjugate symmetric data can arise when computations introduce round-off error.
% 
% Create a vector Y that is nearly conjugate symmetric and compute its inverse Fourier transform. 
% Then, compute the inverse transform specifying the 'symmetric' option, which eliminates the nearly 0 imaginary parts.

Y = [1 2:4+eps(4) 4:-1:2]
% Y = 1×7
% 
%     1.0000    2.0000    3.0000    4.0000    4.0000    3.0000    2.0000 ⋯

X = ifft(Y)
% X = 1×7 complex
% 
%    2.7143 + 0.0000i  -0.7213 + 0.0000i  -0.0440 - 0.0000i  -0.0919 + 0.0000i  -0.0919 - 0.0000i  -0.0440 + 0.0000i  -0.7213 - 0.0000i ⋯

Xsym = ifft(Y,'symmetric')
% Xsym = 1×7
% 
%     2.7143   -0.7213   -0.0440   -0.0919   -0.0919   -0.0440   -0.7213 ⋯

結果如下:

Y =

    1.0000    2.0000    3.0000    4.0000    4.0000    3.0000    2.0000


X =

  1 至 4 列

   2.7143 + 0.0000i  -0.7213 + 0.0000i  -0.0440 - 0.0000i  -0.0919 + 0.0000i

  5 至 7 列

  -0.0919 - 0.0000i  -0.0440 + 0.0000i  -0.7213 - 0.0000i


Xsym =

    2.7143   -0.7213   -0.0440   -0.0919   -0.0919   -0.0440   -0.7213

最後一個例子中用到了eps,關於eps的介紹見博文:

【 MATLAB 】eps (浮點相對精度)簡介