# DFT of a series of RC exponentials

Context: I'm trying use matlab to apply a single-pole filter to a time-domain ramp waveform that is generated by a sequence of time-shifted "RC steps" that are added together.

The time domain voltage waveform is

$$V(t) = \sum_{k=0}^{N-1} V_{step}(1-e^{-(t-k\Delta t_{step})/\tau})u(t-k\Delta t_{step})$$

where $$V_{step}$$ and $$\Delta t_{step}$$ are constants

Using the fft of a one-sided exponential decay, the unit-step, and the time-shift property of the fft I get a frequency domain representation of:

$$\mathfrak{F}(V(t)) = V_{step}\left(\sum_{k=0}^{N-1}e^{-j\omega k\Delta t_{step}}\right)\left(\frac{1}{j\omega} +\pi\delta(\omega) - \frac{1}{\frac{1}{\tau}+j\omega}\right)$$

So now I want to generate this complex-valued fft manually in matlab, multiply by a filter response, and inverse fft. To start, I'm checking the frequency response of the input and its ifft to make sure it looks right:

N=32;
Vstep=25e-3;
tstep=10e-12;
tau=5e-12;
ts=0.1e-12;

Nfft = 2^nextpow2(max([N*tstep/ts N*tau*5/ts])); %Get enough points for the whole ramp with at least 5 tau's per exponenetial
w=(0:Nfft-1)*2*pi/Nff;t
f=w/2/pi/ts;

timeshifts=sum(exp(-1i*(0:N-1)'*w*tstep));
step=[pi 1./(1i*w(2:end))];
expdecay=1./(1/tau+1i*w);

Vf=Vstep*timeshifts.*(step-expdecay);
vt=ifft(V);


So the frequency domain Vf looks reasonable in amplitude. However, when I take the inverse and plot vt, it is definitely not correct.

Where am I going wrong? I suspect there's something I'm missing with the fact that this is a DFT not fourier transform. Also I know there's some subtlety to the FT/DFT of the heaviside, particularly at w=0, and I know that the fft at 0 will just be the average (times N) and I'm not sure my script accomplishes this.

I do know that I can just start with the time domain and then fft it, but I'm rather curious now.

• $V_\mathrm{step}$ and $\Delta t_\mathrm{step}$ are constants? – robert bristow-johnson Feb 1 at 21:41
• Correct they are constants – Kayson Feb 1 at 21:42
• i think you need to move some parenths: $$V(t) = \sum_{k=0}^{N-1} V_\mathrm{step}(1-e^{-(t-k\Delta t_\mathrm{step})/\tau})u(t-k\Delta t_\mathrm{step})$$ – robert bristow-johnson Feb 1 at 21:46
• How so? That's correct to me. The sum applies to the entire expression. – Kayson Feb 1 at 21:49
• your expression is equivalent to: $$V(t) = \sum_{k=0}^{N-1} V_\mathrm{step}(1-e^{-(t+k\Delta t_\mathrm{step})/\tau})u(t-k\Delta t_\mathrm{step})$$ i think you need to consistently subtract $k\Delta t_\mathrm{step}$ from $t$. – robert bristow-johnson Feb 1 at 21:56

okay, for step 1, let's get the continuous time math down right and simplified to as much as possible. i am changing some notational convention slightly to be more consistent with Electrical Engineering practice:

$$v(t) = \sum_{k=0}^{N-1} V_\mathrm{step}(1-e^{-(t-k\Delta t_\mathrm{step})/\tau})u(t-k\Delta t_\mathrm{step})$$

$$V(j\omega) =\mathscr{F}\Big\{v(t)\Big\} = V_\mathrm{step}\left(\sum_{k=0}^{N-1}e^{-j\omega k\Delta t_\mathrm{step}}\right)\left(\frac{1}{j\omega} +\pi\delta(\omega) - \frac{1}{\frac{1}{\tau}+j\omega}\right)$$

there is a well known closed form for the summation of a geometric series:

$$\sum_{k=0}^{N-1} x^k = \frac{x^N -1}{x-1}$$

so

\begin{align} \sum_{k=0}^{N-1} e^{-j\omega k\Delta t_\mathrm{step}} &= \sum_{k=0}^{N-1} (e^{-j\omega \Delta t_\mathrm{step}})^k \\ \\ &= \frac{(e^{-j\omega \Delta t_\mathrm{step}})^N -1}{e^{-j\omega \Delta t_\mathrm{step}}-1} \\ \\ &= \frac{e^{-j\omega N \Delta t_\mathrm{step}}-1}{e^{-j\omega \Delta t_\mathrm{step}}-1} \\ \\ &= \frac{e^{-j (\omega/2) N \Delta t_\mathrm{step}}(e^{-j (\omega/2) N \Delta t_\mathrm{step}}-e^{j (\omega/2) N \Delta t_\mathrm{step}})}{e^{-j(\omega/2) \Delta t_\mathrm{step}}(e^{-j(\omega/2) \Delta t_\mathrm{step}}-e^{j(\omega/2) \Delta t_\mathrm{step}})} \\ \\ &= e^{-j (\omega/2) (N-1) \Delta t_\mathrm{step}}\frac{(e^{j (\omega/2) N \Delta t_\mathrm{step}}-e^{-j (\omega/2) N \Delta t_\mathrm{step}})/(2j)}{(e^{j(\omega/2) \Delta t_\mathrm{step}}-e^{-j(\omega/2) \Delta t_\mathrm{step}})/(2j)} \\ \\ &= e^{-j (\omega/2) (N-1) \Delta t_\mathrm{step}}\frac{\sin(\omega N \Delta t_\mathrm{step}/2)}{\sin(\omega \Delta t_\mathrm{step}/2)} \\ \\ \end{align}

so i think your final expression in continuous frequency of the spectrum should be

$$V(j\omega) = V_\mathrm{step}\frac{\sin(\omega N \Delta t_\mathrm{step}/2)}{\sin(\omega \Delta t_\mathrm{step}/2)} \left(\frac{1}{j\omega} +\pi\delta(\omega) - \frac{\tau}{1+j\omega \tau}\right) e^{-j (\omega/2)(N-1)\Delta t_\mathrm{step}}$$

does that look right to you?

• Looks right. If I replace my geometric series sum with the simplified expression, I get the same result – Kayson Feb 1 at 22:43
• So I generated the time domain representation and fft'd that to compare to my discretized version of the continuous frequency. 1) The DC is different, which is not surprising 2) The time-domain fft has a sinusoid riding on it with a few "rings" that does not appear in the continuous time frequency 3)The high frequency tail of the time domain-fft is nearly flat, whereas the continuous time frequency continues to roll off. I think this is because of the finite length of the time-domain signal. – Kayson Feb 1 at 22:55
• you'll need to do some zero-padding and make your FFT very large, if you want the discrete-frequency results to look like the continuous-frequency results. – robert bristow-johnson Feb 1 at 23:03
• Well the problem is really the other way around. When I inverse fft the continuous frequency results, I don't get anything that looks close to my desired input – Kayson Feb 1 at 23:16
• well, remember the last half of the DFT really represents negative frequency. so you need to put the negative frequency bins in the last half before inverse DFT. the $\delta(\omega)$ is a little bit of a problem. you will have to approximate that Dirac Delta with a Knronecker Delta having the same area. – robert bristow-johnson Feb 1 at 23:35