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 …… 1×9 ……….. 72 ……….. double
b …… 1×9 ……….. 72 ……….. double
y …… 1499400×1 11995200 double
Does anyone have a suggestion on how to resolve this problem?
I understand your frustration. I think the problem is due to the fact that in order to use
filtfiltyou 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 thatfiltfiltis the only function that will meet them. I realize that the zero-phase property of thefiltfiltis 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!