Documentation for ifir (SPASS).

Interpolated FIR filter (generic function)


Description

The function ifir performs a FIR filtering. This is a generic function gathering the functionalities of functions ifir0 and ifir1.

Usage

sig_out = ifir(sig_in,h)
sig_out = ifir(sig_in,h,'0')
sig_out = ifir(sig_in,h,'1')

Arguments

sig_in Input signal. Non Uniform signal.
h Filter transfer function. Non Uniform signal.
interptype Choice of interpolation type. String among '0' and '1'. Optional, default='0'.

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  
nyq = 8;         % half sampling rate = nyquist frequency
fn = fc/nyq;     % normalized cut-off frequency

h = fir1(order,fn);
uh = uinit(h,1/nyq);

% FIR filtering

nuh = h2nuh(uh);
sig0 = ifir(nu,nuh,'0');
sig1 = ifir(nu,nuh,'1');

% Plot result

figure(1)
plot(delay2time(nu.delay,nu.t0),nu.ampl,'k');
hold on
plot(delay2time(sig0.delay,sig0.t0),sig0.ampl,'r');
plot(delay2time(sig1.delay,sig1.t0),sig1.ampl,'r');
hold off