www.gusucode.com > dsp 案例源码程序 matlab代码 > dsp/InverseDiscreteFourierTransformOfASignalExample.m
%% Inverse Discrete Fourier Transform of a Signal %% % *Note*: This example runs only in R2016b or later. If you are using an % earlier release, replace each call to the function with the equivalent % |step| syntax. For example, myObject(x) becomes step(myObject,x). %% % This example analyzes the energy content in a sequence. Fs = 40; L = 128; t = (0:L-1)'/Fs; x = sin(2*pi*10*t) + 0.75*cos(2*pi*15*t); y = x + .5*randn(size(x)); % noisy signal hfft = dsp.FFT; hifft = dsp.IFFT('ConjugateSymmetricInput', true); X = hfft(x); [XX, ind] = sort(abs(X),1,'descend'); XXn = sqrt(cumsum(XX.^2))/norm(XX); ii = find(XXn > 0.999, 1); disp('Number of FFT coefficients that represent 99.9% ') disp(['of the total energy in the sequence: ', num2str(ii)]); XXt = zeros(128,1); XXt(ind(1:ii)) = X(ind(1:ii)); xt = hifft(XXt); %% % Verify that the reconstructed signal matches the original signal. norm(x-xt)