image thumbnail

Filter Characteristics

by

 

Getting of filter characteristics using Matlab.

filter_plot(a,b,tabtast,nfreq)
function [amp,phi,freq,G] = filter_plot(a,b,tabtast,nfreq)


%   a       :a-Koeffizienten vom ARX-Prozess
%   b       :b-Koeffizienten vom ARX-Prozess 
%   tabtast :Abtastzeit
%   nfreq   :Frequenzenvektor-laenge
%   amp     :Amplitudengang
%   phi     :Phasengang
%   freq    :Frequenzenvektor (in 1/Einheit von tabtast)
%   G       :Komplexe Uebertragungsfunktion
%                         

if nargin<4,    nfreq = 1e3;    end
if nargin<3,    tabtast = 1e-3; end
if nfreq<1,     nfreq = 1e3;    end
if tabtast<=0,  tabtast = 1e-3; end

fnyq = 1/2/tabtast;
fmin = fnyq / 300;
freq = logspace(log10(fmin),log10(fnyq),nfreq)';
ex = exp(-j*2*pi*freq*tabtast);

Gb = ones(nfreq,1)*b(1);
Ga = ones(nfreq,1);
na = length(a)-1;
nb = length(b)-1;

exex = ex;
for i=2:nb+1
    Gb = Gb + exex*b(i);
    exex = exex.*ex;
end
exex= ex;
for i=2:na+1
    Ga = Ga + exex*a(i);
    exex = exex.*ex;
end
G = Gb./Ga;
amp = abs(G);
phi = angle(G);

clf
figure,
subplot(211)
loglog(freq,amp,'r-'),grid
xlabel('Kreisfrequenz')
ylabel('Amplitude')

subplot(212)
semilogx(freq,phi,'b+'),grid
xlabel('Kreisfrequenz')
ylabel('Phase [rad]')


Contact us