# Math behind code doing ifft of padded fft and more

accf=fft([zeros(1000,3);acc;zeros(1000,3)]);

cutoff1=0;

X1=[0,0,0;
zeros(round((size(accf,1)-1)/2*cutoff1/50),3);  %% 50 ??
ones(ceil((size(accf,1)-1)/2)-round((size(accf,1)-1)/2*cutoff1/50),3);
ones(floor((size(accf,1)-1)/2)-round((size(accf,1)-1)/2*cutoff1/50),3);
zeros(round((size(accf,1)-1)/2*cutoff1/50),3)];

X2=angle(accf);

X=X1.*exp(X2*sqrt(-1));

acc=real(ifft(X));

acc=acc(1001:end-1000,:);


I guess this is some kind of filtering. Can you help me to find the reference materials for the math?

• if you pad zeros directly on an fft spectrum you are increasing or decreasing frequency. Then when ifft you may obtain a frequency shifted signal. Jan 12 at 9:38

This makes little sense.

1. it zero pads the input on both sides and does an FFT
2. it generates a matrix of the same size with all ones except for the first first row which is zero
3. It copies the phase of the FFT result to the matrix of ones
4. It does an inverse FFT

So it's simply the inverse FFT of the input signal but with the magnitude set 1 (other than DC which is 0)

I'm guessing that this is supposed to generate some sort of rectangular mask window but with setting cutoff1 = 0 it's all just ones and there is really no reason to create the matrix in such a tortured way. You could simply do  X1 = ones(size(accf)); X1(1,:) = 0;

• So this is not a filter? Like high pass or low pass. Because the plot before and after this process is very different. Dec 9, 2022 at 9:19
• It's definitely not a filter Dec 9, 2022 at 9:20
• So what this process is doing and why? Dec 9, 2022 at 9:21
• Of course it's different, the code sets the magnitude of the FFT to 1. That's a highly non-linear operation Dec 9, 2022 at 9:21
• I have no idea. As I said: this makes very little sense. Ask the source. Dec 9, 2022 at 9:22