I am trying to teach myself some signal processing and control theory. I'm currently working through THIS tutorial. I've started an ipython notebook to keep my notes in.
Unfortunately, something is wrong with my very first simulation of a simple first-order low pass filter. The differential equation is $$\dot{x} = \omega_0(u-x)$$ where $u(t)$ is a sinusoidal input. My understanding is that this system is described by the transfer function: $$G(s) = \frac{x(s)}{u(s)} = \frac{1}{1+s/\omega_0}$$ I am interested in using this transfer function to calculate the amplitude and phase lag of $x(t)$. To do this, we evaluate $G$ at $s=i\omega$: $$|G(i\omega)| = \frac{|x(t)|}{|u(t)|} = \frac{1}{\sqrt{1+\omega^2/\omega_0^2}}$$ $$\arg G(i\omega) = \text{phase lag} = -\tan^{-1}\frac{\omega}{\omega_0}$$ Are the above equations correct? Is my interpretation of them correct? Because when I numerically simulate the above differential equation in python, I get results that do not agree. Particularly, the blue dots and red dots should line up with the black lines in my plots. In other words, I have been unable to reproduce Fig. 3 in this tutorial
The ode is so simple, I don't see how I could have messed up the simulation. You can see my code in the links above. Thanks in advance for any comments/suggestions. (P.S. I hope I picked the right stackexchange site for this question, let me know if I got it wrong).
Update: I have tried decreasing the time step for the numerical integration routine, but this does not improve the fit. The code is still available at the same url: [Click here for code]
t = np.linspace(0,30,int(1e4))
). $\endgroup$ – dpwe Jul 24 '14 at 17:38