Hello,
I am going to implement a digital integrator in C. I have decided to use trapezoidal rule in recurrent form i.e. to use following formula
$$I(k) = I(k-1) + \frac{T}{2}\cdot [x(k-1) + x(k)]$$,
where $$T$$ is the period of execution. Please can anybody tell me whether this formula is good choice or any other better ways how to calculate an integral exist? Thanks in advance for any ideas.
#C
Don't bother with the trapezoidal rule; it provides a very small filtering against high-frequency noise, and if you're using a control feedback system you need to manage the phase lag caused by filtering/delays.
It depends on the purpose of the integrator. If it's just for integral calculation, then the forward approximation is more simple,
I(k)=I(k-1)+T*x(k)
If it's for feedback control, then frequency-domain response could be important as already mentioned by others. In that case, comparing different implementation methods in frequency domain should be helpful, and this can be done easily with Matlab.