![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1409374/image.png)
How do I use MATLAB Coder to generate C++ code for an IIR filter that was generated by designfilt?
16 次查看(过去 30 天)
显示 更早的评论
I have the file gpsFilterTest.m with:
Fpass = .5;
Fstop = 1;
Ap = .5;
Astop = 80;
FsampleRate = 10;
dellip = designfilt('lowpassiir','PassbandFrequency', Fpass,...
'StopbandFrequency', Fstop, 'PassbandRipple', Ap,...
'StopbandAttenuation',Astop,'SampleRate',FsampleRate, 'DesignMethod', 'ellip');
gpsData = 0:1:1000;
gpsIndex = gpsData;
gpsData = gpsData + transpose(randn(1001,1));
filteredGpsData = gpsFilter(gpsData);
plot(gpsIndex,filteredGpsData);
I have the file gpsFilter.m with:
function filteredGpsData = gpsFilter(gpsData)
%#codegen
filteredGpsData = filter(dellip,gpsData);
end
I get this error when I try to automatically define input types:![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1409304/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1409304/image.png)
I hope the answer to this question will help others besides me.
0 个评论
回答(1 个)
Raghava S N
2023-6-13
编辑:Raghava S N
2023-6-13
So, first of all, the dellip argument should be declared inside the gpsFilter function, because code generation does not support arrays of classes as function parameter. Once you declare dellip inside gpsFilter by sending Fpass,Fstop,Ap,Astop,FsampleRate as parameters to gpsFilter, MATLAB Coder gives the following error:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1409374/image.png)
Do check out the following articles on how to solve this issue.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!