Matlab - Bode plot of Lag Filter + Integrator I am rather new to Matlab and I just cant make sense of what I see in the bode plot of the continuous and discrete version of the same function. The bode plot of the continuous function looks as expected. However the bode plot of the discrete version has a phase offset of +90 degrees and the gain stays the same at lower frequencies. It's basically a lag compensator with an integrator. This is not the final result I am going for, but the easiest example I could think of to make the problem as clear as possible. Please note that I am using a rather high sampling rate of ~12 MHz, which is what I need in the final hardware design. The high sampling rate seems to be part of the problem. With lower sampling rates the frequency at which the bode plots differ gets shifted to the left.

Can anyone explain this behaviour and maybe how I can achieve a result that is closer to the continuous bode plot using the high sampling rate?

Code of the example:

FS = 48000*256;
T_sample = 1/FS;

accu = tf([0 1], [1 0]);
lag = tf([10 1], [100 1]);

lag_d = c2d(lag, T_sample, "zoh");
accu_d = c2d(accu, T_sample, "zoh");

bode(lag*accu, lag_d*accu_d);
I tried it in Octave, there's definitely a glitch like you said. I tried it with "Tustin" instead of "zoh", same result. 

However I was puzzled by your high sampling frequency. Your lag controller has a pole at s = -0.01 and a zero at s = -0.1, they are both "slow" while your sampling frequency is really high.

How to fix it : 
Change your sampling frequency to something much lower than 12 MHz, like 10 kHz for instance and replace "zoh" by "tustin". "Zoh" should only be used when converting a "process" transfer function to the discrete domain in order to take in account the effect of the DAC, we don't use it for compensators.

The root cause however is probably some quantization issue in the c2d function. 

FS = 10e3;
T_sample = 1/FS;

accu = tf([0 1], [1 0]);
lag = tf([10 1], [100 1]);

accu_d = c2d(accu, T_sample, "tustin");
lag_d = c2d(lag, T_sample, "tustin");

figure
bode(lag*accu, accu_d*lag_d);


Edit 1 :

The issue seems to be with the lag controller, not the accumulator. You should try to move the pole and the zero to the left, this should fix your problem since you must keep your sampling frequency really high:

try this (same DC gain, but pole and zero further to the left) : 

lag = tf([1 1000], [10 1000]);