| Description |
This file takes a filter in sos sections and converts it into a C# class. It "unwinds" the sos stages explicitly without looping for speed...it runs faster under managed C# than it does under Matlab.
For example, to design a sos filter:
H = design(fdesign.highpass('fst,fp,ast,ap',250, 300, 20, 3, 1000),'cheby1','MatchExactly', 'passband');
Then to convert the sos sections into C# code:
sos2csharp(H,'filter.cs')
This creates the C# class filter.cs file in the current working directory. Add it to your C# solution. To call it within C#, for instance,
double[] x {1.0, 2.0, 4.0, 2.0}; // input data
double[] y = new double[4]; // output data
Filter myFilter = new Filter();
myFilter(x, y); // the filtered data is now in array y
double[] x1 {4.0, 2.0, 7.0, 1.0}; // new input data
myFilter(x1, y); // the initial conditions are saved, so this is
// same as if you gave it the concatenation of [x x1] |