| Prev | Next | gainz |
| Syntax |
y = gainz(bz,az,f,fs) |
| Include: |
include spt\gainz.oms |
| See Also | Other Window Functions |
ARGUMENTS:
INPUTS:
bz = COLUMN VECTOR, numerator polynomial in z^(-1).
az = COLUMN VECTOR, denominator polynomial in z^(-1).
f = MATRIX, any type, evaluation frequencies [Hz].
fs = SCALAR, any type, sampling rate, [Samples/sec].
RETURN: MATRIX, COMPLEX, gain at input frequencies.
Calculate the complex gain of a rational digital transfer function.
Arguments 'bz' and 'az' are column vectors representing the
numerator and denominator polynomials, respectively, of a
digital transfer function in z-transform form. The
represented function has the form:
bz(z) b(1) + b(2)*z^(-1) + b(3)*z^(-2) + ... + b(Nb)*z^(-N)
----- = -----------------------------------------------------
az(z) a(1) + a(2)*z^(-1) + a(3)*z^(-2) + ... + a(Ma)*z^(-M)
where: N = numerator polynomial order
M = denominator polynomial order
Nb = rowdim(bz), N = Nb-1
Ma = rowdim(az), M = Ma-1
z = exp(-j*2*PI*f*t/fs), j=sqrt(-1)
The transfer function is evaluated at the frequencies in [Hz]
contained in input matrix 'f'. The system sampling rate is
specified through argument 'fs' [Hz]. These two arguments are
coerced to DOUBLE for local processing.
The function returns a COMPLEX matrix of the same dimensions
as 'f'. Absolute value of this return gives frequency
response magnitude.
include spt\gainz.oms # include gains() function
b = novalue; # Declare numerator polynomial
a = novalue; # Declare denominator polynomial
fnbut(3,b,a); # Make an order = 3 Butterworth function
fs = 1d3; # Set the sampling frequency
fc = 1d0; # Set the lowpass cutoff frequency
fn2dlp(2d0*PI*fc,1d0/fs,b,a,b,a) # Convert to a digital transfer function
f = {fc/10d0, fc, fc*10d0}; # Make a frequency evaluation vector
H = gainz(b,a,f,fs) # Find the complex gain
format complex "f10.6"
H # Print the gain results
The results are:
{
( 0.979999, -0.198999)
( -0.500000, -0.500000)
( -0.000199, 0.000979)
}