Here's MIM (Magnitude Invariance Method) paper (press the "View PDF" to get the paper/matlab code in hands) and here's a plot showing the issue I'm trying to solve:
Magnitude responses for one pole LP filter at few frequency locations.
As plot shows, there's some issue in MIM's function c2dn() implementation, which 'moves' the fc point especially at low fc values. IIRC, same type of issue happens when changing the fs.
Analog prototype LPF is calculated as:
Code: Select all
w0 = 2*pi*fc;
Analogb = 1;
Analoga = [1 w0];
Analog = tf(Analogb, Analoga);
Analog = Analog/dcgain(Analog);
Code: Select all
fs=44100;
mimpim = 'mim';
samplingtime = 1/fs;
numofsamples = 2048;
[Dz1] = c2dn(Analog, samplingtime, mimpim, 1, numofsamples);
%[a2, b2, T] = tfdata(Dz1); %coeffs
Plotting:
Code: Select all
fs2 = fs/2;
nf = logspace(0, 5, fs2);
[mag, pha] = bode(Analog,2*pi*nf);
semilogx(nf, 20*log10(abs(mag)), 'color', 'g', 'linewidth', 1.5);
axis([10 fs2 -50 1]);
hold on;[mag, pha] = bode(Dz1,2*pi*nf);
semilogx(nf, 20*log10(abs(mag)), 'color', 'k', 'linewidth', 1.5, 'linestyle', '--');grid on;
title('Various TF (LPF 1)');
legend('Analog', 'MIM','location', 'southwest');
xlabel('Hz');ylabel('dB');
Here's plot showing the effect of my correction f(x):
Correction formula
Code: Select all
f(x) = 0.9704384746x - 51.6991952722
Any suggestions regarding the source for this "error"?