How can I use single float with filtfilt in matlab coder?

3 visualizaciones (últimos 30 días)
WillandSmith
WillandSmith el 19 de Jun. de 2017
Comentada: Jan el 4 de Jul. de 2017
I use matlab coder (matlab version:R2017a) to compile matlab code to C code .And I want to use single floating-point number.While I have used filtfilt function in matlab code. Then I got an error it said filtfilt only takes double floating-point number.I have tried using single() to convert parameters in filtfilt but still failed.Is there anyone can help me?Thanks.

Respuestas (1)

Jan
Jan el 19 de Jun. de 2017
Editada: Jan el 19 de Jun. de 2017
Either convert the signal using double(), or use FEX: FilterM, which accepts single values, but accumulate the internal filter state as doubles to increase the accuracy or the output.
  4 comentarios
WillandSmith
WillandSmith el 22 de Jun. de 2017
Thanks Jan.The FilterX.c is indeed a C file, but I still have many other matlab code and I want to complile them all into C code using matlab coder so that I don't have to rewrite all the matlab project to C code. Further more the target platform is ARM. So I have to use single-precision for reducing running time. I read your answer carefully but can't get the point to solve my problem.
Jan
Jan el 4 de Jul. de 2017
While filter works on single also, filtfilt accepts doubles only (at least in some Matlab versions). You can either include the C-Mex FilterX and FiltFiltM.m (see https://www.mathworks.com/matlabcentral/answers/48620-generating-c-c-code-from-m-function-include-mex-file), or modify the builtin filtfilt.m function to accept singles also. I still do not see, where the problem is.

Iniciar sesión para comentar.

Categorías

Más información sobre Statistics and Linear Algebra en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!