Convert Matlab SOS filters to C#
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]
인용 양식
James Squire (2025). Convert Matlab SOS filters to C# (https://kr.mathworks.com/matlabcentral/fileexchange/23530-convert-matlab-sos-filters-to-c), MATLAB Central File Exchange. 검색 날짜: .
MATLAB 릴리스 호환 정보
플랫폼 호환성
Windows macOS Linux카테고리
태그
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!