Example code:
Code: Select all
fs = 44100;
%% analog model
a2 = [0.000015 1];
b2 = [0.000050 1];
Ds = tf(a2, b2);
Ds = Ds/dcgain(Ds);
%% digial 1
B1 = [1 -0.62786881719628800 0];
A1 = [-0.08782333709141920 0.45995451989513100 0];
Dz = tf(A1, B1, 1/fs);
Dz = Dz/dcgain(Dz);
%% digital 2
B2 = [1 0.8868033819284362 -0.312597640666886 -0.3462305068062579 -0.04427163895789011];
A2 = [0.4601686131709282 0.6087942052682088 0.1563216019782706 -0.03386380454131521 -0.007717020378690522];
Dz2 = tf(A2, B2, 1/fs);
Dz2 = Dz2/dcgain(Dz2);
wmin = 2 * pi * 20; % 20Hz
wmax = 2 * pi * (fs/2);
bode(Ds, 'r', Dz, 'k', Dz2, 'g', {wmin, wmax});
legend('Ds', 'Dz1', 'Dz2','location', 'northwest');
% plot errors