facing problem regarding fft and ifft use

2 views (last 30 days)
Amit
Amit on 4 Dec 2014
Edited: Amit on 4 Dec 2014
assignin('base', 'PClean',eval(['PClean_',num2str(ii)]));
PClean=PClean(1:110000,1);
PClean(1,1)=0;%as 1 element is form 0 frequency and 0 sec .so no reading
assignin('base', 'Pdisturbed',eval(['Pdisturbed_',num2str(ii)]));
Pdisturbed=Pdisturbed(1:110000,1);
Pdisturbed(1,1)=0;%as 1 element is form 0 frequency and 0 sec .so no reading
% Fast Fourier Analyse
% Input
[FFT_PClean] = fft(PClean,length(PClean));
%fft on the entire length of your time series clean signal, length(PClean_f)
FFT_PClean((length(PClean)/2)+2)=[];
%The other half of the fft about the Nyquist frequency (freq/2) is the ...
%...complex conjugate of the first half and therefore mirror images the first half.So throw it away with any loss of information.
%Calculate spectra for clean signal, SPClean from the fft above
[SPClean]=2*((FFT_PClean.*conj(FFT_PClean)/length(PClean))/freq);
%freq is the sampling frequency. The spectrum should be scaled by the length of the time series data ,length(PClean_f) and by the sampling frequency freq
% Output is operated same as above
[FFT_Pdisturbed] = fft(Pdisturbed,length(Pdisturbed)); % length(Pdisturbed_f) should be equal to length(PClean_f) to get the correct frequency ratio.
% Both the clean and corrupt data at the same sampling rate and for the same duration.
FFT_Pdisturbed(length(Pdisturbed)/2+2)=[];%Same as the clean signal. Throw out the mirror image
%Calculate spectra for disturbed signal, SPdisturbed
[SPdisturbed]=2*((FFT_Pdisturbed.*conj(FFT_Pdisturbed)/length(Pdisturbed))/freq);
TFunct= SPClean./SPdisturbed;
TFunct(1,1)=0;
%This is the transfer function which can be used to convert the spectrum of corrupt data that is being measured %thereafter in the tunnel using the tubings of similar length and diameter [similar to the one used to establish your transfer function].
df = freq/length(PClean); %frequency resolution
f = 0:df:freq/2; % frequency vector corresponding to the transfer function; freq/2 is called the Nyquist frequency
f=f';
TFunct=TFunct(1:length(f),1);
T(ii,1:length(f))=TFunct_transpose;
close
end
TFunct_final=mean(T);
TFunct_final=transpose(TFunct_final); [SPCleanobtianed]=TFunct_final.*SPdisturbed(1:length(f),1);
P=ifft(SPCleanobtianed);% I do not know how to make ifft of this.I am not getting the results as expected
filename=sprintf('TFunct_final_%d',sn); save(filename,'TFunct_final');
end close all

Answers (0)

Community Treasure Hunt

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

Start Hunting!