# Filtering when collecting a signal in the time domain

I reconstructed a signal (from simulations) in the time domain from t ~ 0.01 to 2000 s. I do this by calculating "modes" or constants for the system that I'm studying that should be exact and then constructing the time-domain signal from a formula, with a sample rate for the time-domain signal of 10 kHz (I chose 10 kHz somewhat arbitrarily since it corresponds to a time far less than the shortest mode). I then wish to take the FFT.

The signal is not bandlimited. I don't think the signal in the time-domain should have any aliasing. To take the FFT, I sampled up to the Nyquist frequency of 5 kHz, but I understand that since the signal isn't bandlimited, I probably cannot do this. Also, there are features at higher frequencies (within half the Nyquist or so) that don't make sense physically, but I have no clear a priori knowledge of where the cutoff frequency / passband should be.

My understanding is that I can / should apply an anti-aliasing filter when reconstructing the original signal in the time domain and then take the FFT. Can somebody please clarify my thinking on this? My background is in physics not signal processing, and I feel that I'm getting a lot of these concepts muddied.

• So you are working with sampled analog data, or generating the samples with some formula? Either way, the sampled analog signal already has aliases folded back into it if they were not filtered away before sampling. The generated samples might too depending on how you generated them - digitally generating a 6 kHz sine wave at 10 kHz sampling rate will give you a 4 kHz sine. You can take FFT of the samples anytime, the samples contain information up to 5 kHz. Only if you play the digital samples back with a DAC, you need an analog reconstruction filter after DAC. Jul 8, 2022 at 4:58
• I am generating the time-domain signal with a formula based on the modes that I have calculated.
– user314730
Jul 8, 2022 at 5:07
• I can't say I understand what that means, but since your sampled input had aliasing errors you can't get rid of, and it only contained frequencies up to 5 kHz, your model you use to regenerate the signal is also based on erroneus data, and also won't contain frequencies over 5 kHz. So why would you need filtering of generated samples? Jul 8, 2022 at 5:11
• Does this answer your question? How to remove aliasing effects? Jul 8, 2022 at 8:21
• What are these "modes"? Does the FT exist for them already? If so, then just do that, and add up all the components: FT is a linear transform. And if not, your task is probably hopeless because it's not a "signal" (in terms of continuity and other well-behaved properties). Jul 8, 2022 at 14:48

My understanding is that I can / should apply an anti-aliasing filter when reconstructing the original signal in the time domain and then take the FFT

It's too late to apply anti-aliasing after you have the sampled data. The anti-aliasing filter must be done before the data is sampled. After it is sampled anti-aliasing muddles everything up.

In your case, it sounds like your data source is not real world measurements but analytic equations. In which case, you need to apply the anti-aliasing filter to the numeric results of the equation as you spit out the numbers, and you need to spit them out with greater frequency than what you want your final bandwidth to be. At least, twice as frequent as the highest frequency component of interest. This might still be insufficient in this particular weird case though where your output data source is discrete and here it starts veering into mathematics I am not familiar with. I'm pretty sure it depends on the behaviour of those equations you are working with. You might want to go eight or 16 times more frequent or even more just to be safe and then anti-alias that. Maybe even more 64x or 128x to better approximate an continuous time signal relative to your final sampled signal.

You'll probably want to use FIR filters for the anti-aliasing part.

A reconstruction filter is different than an anti-aliasing filter.

• +1 Thanks so much @DKNguyen. Yes, you're right (sorry if I was unclear) that the data source is an analytic equation. I'll work on trying what you suggested using an FIR filter as I understand it.
– user314730
Jul 8, 2022 at 5:49
• If you wouldn't mind, could you please comment on why you suggested an FIR filter for the anti-aliasing part? And if there are any specific ones you recommend?
– user314730
Jul 8, 2022 at 5:56
• @user2561523 If you're filtering on digital data then you need a digital filter and they're are just easier to use than IIR filters. You'll probably need to use some filter design software unless you want to rabbit hole. Depending on what you have access to MATLAB and software like it can have such a design module already built in where you input parameters and it will spit out the coefficients. Jul 8, 2022 at 20:51

You cannot do better than just using your samples and taking the fft of them. Do not try to reconstruct the signal in some way and then take the fft, there is no advantage to this.