I have a current signal (extracted in csv) which I obtained from cadence simulation over 30ns time. I have removed DC offset and applied windowing function before FFT. And normalized FFT by sqrt(N)
. I have shift zero-frequency component to center of my desired spectrum with fftshift(X)
. I got my desired FFT. I also want to get back to my original windowed signal by ifft
but it is not showing my windowed signal instead it is showing only a version of the window function that I used. My sample signal is real not complex.
I have another question. My power before FFT and after FFT is same. How can I show in graph in an intelligent way to show Parseval's theroem?
I have also added my MATLAB code without the uploading csv and making the vectors. my y
value is Current_wo_dc
MATLAB Code:
N = length(Current_wo_dc);
ts = 1.0e-12;
Fs = 1/ts;
tmax = (N-1)*ts;
tm = 0:ts:tmax;
f = -Fs/2:Fs/(N-1):Fs/2;
fn=hanning(N); % hanning window function
Z = Current_wo_dc'.*fn;
Power_Z = sum(Z.^2); % power in time domain
%FFT
fftY = fft(Z);
y = fftshift(fftY);
Y = abs(y);
a3 = Y/sqrt(N);
Power_fftY = sum(fftY.*conj(fftY))/length(fftY); % power in frequency domain
%IFFT:
I = ifftshift(fftshift(Z));
II = I*sqrt(N);
%PSD
psd = a3.^2;
psd_db = 10*log10(psd);
subplot(311), plot(Z); % windowed signal
subplot(312), plot(a3); % fft across frequency bin not shifted along frequency
subplot(313), plot(II); % ifft