# Arbitrary response magnitude and phase filter

## Syntax

Hd = arbmagphase (Nb,Na,mag,phase,freq,Type,DFormat)

## Description

Find the poles and zeros of an unknown filter from its complex frequency response specification, $$H(k)$$. Where, $$mag= 20{log}_{10}(\left|H(k)\right|), phase =\frac{180}{\pi}arg\ (H(k))$$ and $$freq = 0 \rightarrow Nyquist$$ in Hz. Data may have gaps, and is not required to have equally spaced incremental frequency steps between 0 and Nyquist. Use the fsunits keyword to scale a normalised frequency specification into Hz.

Nb: The number of zeros(0-20) to be fitted to the data. If you want to create all-zero model, set Na=0
Na: The number of poles (0-20) to be fitted to the data. If you want to create all-pole model, set Nb=0
Mag, phase and freq: the complex frequency response data in dB, degrees and Hz.
Type: real produces a real filter, whereas complex produces a complex filter.

DFormat: allows you to specify the display format of resulting digital filter object.

 symbolic Display a symbolic representation of the filter object. numeric Display a matrix representation of the filter object void Create a filter object, but do not display output

## Example

ClearH1;  // clear primary filter from cascade
ShowH2DM;

interface Na = {0,10,1,5}; // interface variable definition
interface Nb = {0,20,1,6}; // interface variable definition

freq=H(:,0); // extract frequency specification (Hz)
mag=H(:,1);  // extract magnitude specification (dB)
phase=H(:,2); // extract phase specification (degrees)

Main()

// design a "real" filter from the specification
Hd=arbmagphase(Nb,Na,mag,phase,freq,"real","symbolic");

Num = getnum(Hd); // define numerator coefficients
Den = getden(Hd); // define denominator coefficients
Gain = getgain(Hd); // define gain