Documentation for iir (SPASS).

IIR filter (generic function)


Description

The function iir performs a IIR filtering. This is a generic function gathering the functionalities of functions iirbilinear, iirEuler, iirEulerbw, iirint0, iirint1, iirintnn, iirRK23 and iirRK4.

Usage

sig_out = iir(sig_in,fsm)
sig_out = iir(sig_in,fsm,'Euler')
sig_out = iir(sig_in,fsm,'bwEuler')
sig_out = iir(sig_in,fsm,'bilinear')
sig_out = iir(sig_in,fsm,'RK4')
sig_out = iir(sig_in,fsm,'RK23')
sig_out = iir(sig_in,fsm,'int0')
sig_out = iir(sig_in,fsm,'int1')
sig_out = iir(sig_in,fsm,'intnn')

Arguments

sig_in Input signal. Non Uniform signal.
fsm Filter state matrix. Filter state matrix.
scheme Choice of discretization method. String among 'bilinear', 'Euler', 'Eulerbw', 'int0', 'int1', 'intnn', 'RK23' and 'RK4'. Optional, default='RK4'.

Values

sig_out Filtered output signal. Non Uniform signal.

See Also

Example

% Creation of a non uniform signal

f = 1;           % signal frequency
t = 10/f;        % signal duration
fs = 1000;       % sampling frequency
ts = 1/fs;       % sampling time
t0 = 1.;         % initial time
times = t0+(0:ts:t); % time samples
a = 0.45;        % signal amplitude

ampl = a*sin(2*pi*f*times)+a*sin(4*2*pi*f*times)+0.9;   % amplitudes

u = uinit(ampl,ts,t0);

% Level crossing

levels = [.1 .4 .7 1.1 1.4 1.7];
nu = levelcross(u,levels);

% Creation of a uniform filter

fc = 2;          % cut frequency
order = 10;      % filter order  
wc = 2*pi*fc;    % cut pulsation

[A,B,C,D] = butter(order,wc,'s');
fsm = fsminit(A,B,C,D);

% FIR filtering

sigbilinear = iir(nu,fsm,'bilinear');
sigEuler = iir(nu,fsm,'Euler');
sigEulerbw = iir(nu,fsm,'Eulerbw');
sigint0 = iir(nu,fsm,'int0');
sigint1 = iir(nu,fsm,'int1');
sigintnn = iir(nu,fsm,'intnn');
sigRK23 = iir(nu,fsm,'RK23');
sigRK4 = iir(nu,fsm,'RK4');

% Plot result
% Explicit methods

figure(1)
plot(delay2time(nu.delay,nu.t0),nu.ampl,'k');
hold on
plot(delay2time(sigEuler.delay,sigEuler.t0),sigEuler.ampl,'r');
plot(delay2time(sigint0.delay,sigint0.t0),sigint0.ampl,'b');
plot(delay2time(sigRK4.delay,sigRK4.t0),sigRK4.ampl,'g');
hold off
axis([1 11 0 1.8]);
legend('initial','Euler','order 0 integral','RK4');
% Plot result
% Implicit methods

figure(2)
plot(delay2time(nu.delay,nu.t0),nu.ampl,'k');
hold on
plot(delay2time(sigEulerbw.delay,sigEulerbw.t0),sigEulerbw.ampl,'r');
plot(delay2time(sigbilinear.delay,sigbilinear.t0),sigbilinear.ampl,'b');
plot(delay2time(sigintnn.delay,sigintnn.t0),sigintnn.ampl,'g');
plot(delay2time(sigint1.delay,sigint1.t0),sigint1.ampl,'m');
plot(delay2time(sigRK23.delay,sigRK23.t0),sigRK23.ampl,'c');
hold off
axis([1 11 0 1.8]);
legend('initial','backward Euler','bilinear','nearest neighbor integral','linear integral','RK23');