Convert transfer function from zero-pole to numerator-denominator form.
Convert a rational polynomial defined with zeros Z and poles P and gain K in to its numerator Num and denominator Den form. The numerator will be scaled by K and both polynomials are assumed to have only real coefficents. (Poles and zeros can still be complex, if they have complex conjugated pairs.)
Example 1
The following example computes the coefficients of the rational polynomial. The numerator has zeros at 3 and 4 and the denominator has zeros at 1 and 2. The polynomial in zero pole form can be written as:
(x - 3)*(x - 4)
---------------
(y - 2)*(y - 1)
And in transfer function form:
x^2 - 7*x + 12
--------------
x^2 - 3*x + 2
Notice that powers are falling from left to right. Code example:
uses MtxExpr, Math387, MtxVec, MtxVecTee, MtxVecEdit, LinearSystems;
procedure TForm1.Button1Click(Sender: TObject);
var z,p,num,den: Vector;
k: TSample;
begin
z.SetIt(false,[3,4]);
p.SetIt(false,[1,2]);
k := 1;
ZeroPoleToTransferFun(num,den,z,p,k);
ViewValues(num);
ViewValues(den);
// num = [1, -7, 12]
// den = [1, -3, 2]
end;
#include "MtxVecCPP.h" //MtxVecCPP.cpp must be included in the project
#include "MtxVecEdit.hpp"
#include "MtxVecTee.hpp"
#include "SignalUtils.hpp"
#include "LinearSystems.hpp"
void __fastcall TForm41::BitBtn1Click(TObject *Sender)
{
Vector z,p,num,den;
double k;
z->Size(2);
z[0] = 3;
z[1] = 4;
p->Size(2);
p[0] = 1;
p[1] = 2;
k = 1;
ZeroPoleToTransferFun(num,den,z,p,k);
ViewValues(num);
ViewValues(den);
// num = [1, -7, 12]
// den = [1, -3, 2]
}
using Dew.Math;
using Dew.Math.Editors;
using Dew.Math.Units;
using Dew.Signal;
using Dew.Signal.Units;
using Dew.Math.Tee;
using Dew.Signal.Tee;
private void button1_Click(object sender, EventArgs e)
{
Vector z = new Vector(0);
Vector p = new Vector(0);
Vector num = new Vector(0);
Vector den = new Vector(0);
double k;
z.SetIt(false,new double[2] {3,4});
p.SetIt(false,new double[2] {1,2});
k = 1;
LinearSystems.ZeroPoleToTransferFun(num,den,z,p,k);
MtxVecEdit.ViewValues(num,"Numerator",true);
MtxVecEdit.ViewValues(den,"Denominator",true);
// num = [1, -7, 12]
// den = [1, -3, 2]
}