Question

I'm trying to use the filtfilt command with matlab coder but I am running into trouble.

If I run the program the normal way everything runs fine, but when I try to build for c-code the following error message is displayed: "Data must have length more than 3 times filter order". I read somewhere that this may be because the filtfilt function need to know the entire signal (over time) and this may be incompatible with matlab coder. This however seems incorrect as matlab lists filtfilt as a supported function for Code generation - http://www.mathworks.se/help/toolbox/signal/ug/br7exek-1.html

My call is:

y_filt=filtfilt(b,a,y);

My variables just before the call have the following properties:

Name Size .......... Bytes ...... Class

a ...... 1x9 ........... 72 ........... double
b ...... 1x9 ........... 72 ........... double
y ...... 1499400x1 11995200 double

Does anyone have a suggestion on how to resolve this problem?

Was it helpful?

Solution

I understand your frustration. I think the problem is due to the fact that in order to use filtfilt you pre-allocate a massive amount of data. When I try a similar operation my machine, which is considered a server class, runs out of memory. I would recommend looking at your requirements and make sure that filtfilt is the only function that will meet them. I realize that the zero-phase property of the filtfilt is perfect for distribution in Matlab Coder, however the memory requirements may give you more headaches still. Let me know if you wish to discuss other alternatives. Thanks!

OTHER TIPS

you use a Buuterwroth-Filter here. This is an IIR filter. The filter order that is asked by can be much higher than the number of filter tabs. And the signal length should be three times the filter order, not the filter length!

Regards, Tchekov

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top