Implementation of the filter function (Matlab) C/C++

11 ビュー (過去 30 日間)
Durian Odour
Durian Odour 2017 年 11 月 19 日
回答済み: Jan 2017 年 11 月 20 日
I am trying to apply some filtering in C/C++ code, I have designed an algorithm using `Matlab` and it works well, so now I am moving it to native code.
I am interested in the filter function. In my matlab script it is used as follows.
[y_blk, fir1_state] = filter( h, 1, x.*c, fir1_state );
Where the `h` argument is coefficients generated by `firpm` function.
I have tried to find any implementation, but unfortunately no results.
I would be very grateful if someone could provide an implementation of this function
Or maybe there is an existing implementation of this function in some library.
Thanks
  2 件のコメント
Walter Roberson
Walter Roberson 2017 年 11 月 19 日
Which release are you using? In R2017b, MATLAB Coder should be able to generate C/C++ code for this
Durian Odour
Durian Odour 2017 年 11 月 19 日
I am using R2017 matlab, however it generates code with hardcoded values like that
void b_filter(const double b[401], const double x_data[], const int x_size[1],
const emxArray_real_T *zi, double y_data[], int y_size[1], double
zf[400])
{
int nx;

サインインしてコメントする。

採用された回答

Jan
Jan 2017 年 11 月 20 日
You find the M-code, which creates the same output as filter here. A C code is contained in https://www.mathworks.com/matlabcentral/fileexchange/32261-filterm. There are some subfunctions for unrolled loops. I still plan to publish the the multi-threaded version with different implementations for IIR and FIR filters. But based on the provided code you might create the wanted filter easily by your own.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDigital Filter Design についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by