How to use INVERSE FFT in matlab on csv data?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
i have a csv file on which i performed fourier transform on the data. But now i'd like to apply inverse FFT to get back to the time signal from frequency domain.
how can the code be written??
below is how fft was applied to data. data = csvread('TEK00000.csv'); x=data(:,1); y=data(:,2); L = numel(x); % Signal Length (Samples) Fs = mean(diff(x)); % Sampling Frequency (Hz) Fn = Fs/2; % Nyquist Frequency (Hz) nfft2=2^nextpow2(L); % Desired Fourier Transform Length ymc = y-mean(y); % Subtract Mean (Eliminates d-c- Offset) FTy = fft(ymc, nfft2)/L; % Fourier Transform (Scaled By Length Of Data Vector) Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector (One-Sided Fourier Transform) Iv = 1:numel(Fv); % Index Vector [pks,locidx] = findpeaks(abs(FTy(Iv))*2, 'MinPeakDistance',20, 'MinPeakHeight',2E-3); % Peak Amplitudes & Indices figure(2) subplot(2,1,1) plot(Fv, abs(FTy(Iv))*2) grid xlim([0 1.5E-6]) title('FFT Magnitude') grid minor xlabel('Frequency [Hz]'); ylabel('Amplitude [mV]'); text(Fv(locidx), pks, sprintfc('%11.2E Hz\n%11.2E mV', [Fv(locidx)' pks]))
%%%%%%%%% below is my attempt on ifft%%%%%%%%%%%%%%%%
long2 = length(Fv); inverse = ifft(FTy,nfft2)/long2; % xx =inverse(:,1); % yy = inverse(:,2); subplot(2,1,2) plot(long2,inverse)
%%please correct me on the InverseFFT. thanks%%%
0 Kommentare
Antworten (1)
Star Strider
am 27 Sep. 2018
You need to do the ifft on ‘FTy’.
You will likely need to multiply ‘FTy’ by ‘L’ first. The ifft result will not be exactly the same as ‘y’ because of using ‘nfft2’ to change (zero-pad) ‘y’ before doing the fft.
If you simply want to experiment with ifft, simply do:
FTy2 = fft(ymc);
y2 = ifft(FTy2);
and then plot each one of them separately.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Fourier Analysis and Filtering finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!