ndarray-freqz

1.0.0 • Public • Published

ndarray-freqz

Compute the frequency response of a digital filter based on it's transfer function.

Introduction

This scijs compatible module calculates the frequency response of a given transfer function, described by the coefficient of the numerator and denominator polynomials.

|           jw              -jw            -jmw
|    jw  B(e)    b[0] + b[1]e + .... + b[m]e
| H(e) = ---- = ------------------------------------
|          jw               -jw            -jnw
|        A(e)    a[0] + a[1]e + .... + a[n]e

Inspired by the scipy.signal.freqz function.

Sample usage:

var freqz = require('ndarray-freqz')
 
var b = [0.5, 0.5];
var a = [1];
 
var fr = freqz(b, a);
 
fr.H_r // real part of the frequency response.
fr.H_i // imaginary part of the frequency response.
 
var magnitude = zeros([512])
 
cops.mag(magnitude, fr.H_r, fr.H_i);
 

Install

$ npm install ndarray-freqz

API

freqz( b, a, [omega] )

Compute the frequency response of a digital filter based on it's transfer function.

  • b Array/ndarray of the numerator polynomial coefficients of the filter transfer function.
  • a Array/ndarray of the denominator polynomial coefficients of the filter transfer function.
  • omega Optional Array/ndarray of frequency (in radians/sample) values to calculate the frequency response for. If the value is a Number, then frequency response will be calculated for that many frequencies equally spaced around the unit circle. If undefined then frequency response will be calculated at 512 frequencies equally spaced around the unit circle.

Returns a object with following components

  • H_r ndarray of the real part of the generated frequency response.
  • H_i ndarray of the imaginary part of the generated frequency response.
  • omega ndarray of the frequencies of the generated frequency response.

Credits

(c) 2016 Chinmay Pendharkar. MIT License

Package Sidebar

Install

npm i ndarray-freqz

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • notthetup