How to convert Matlab code(Decimate Function) to C code?
显示 更早的评论
Hi everyone,
I'm trying to convert Decimate function to C code using MATLAB coder. But generation failed with the error, "All inputs must be constant" for cheby1 function in decimate.m file. The part of code is as shown:
function odata = decimate (idata, r, nfilt, option) %#codegen
...
...
[b,a] = cheby1(nfilt, rip, .8/r);
while all (b==0) || (abs(filtmag_db(b,a,.8/r)+rip)>1e-6)
nfilt = nfilt - 1;
if nfilt == 0
break
end
[b,a] = cheby1(nfilt, rip, .8/r); %The error line
end
...
...
I call the decimate function to a main math file in my project. I read the information about cheby1 function (https://www.mathworks.com/help/signal/ref/cheby1.html) and I understand why error occured because of the statement :"All inputs must be constants. Expressions or variables are allowed if their values do not change"
I think when the variable -nfilt- changes, dimensions of arrays(b,a) changes. So we can not use that arrays (changing dinamically their dimension) in C code.
How can I modify this code? Could you help me please?
I specify b= zeros(50,1) and a = zeros(50,1) before. But it is not working.
Is there anyone have an idea to modify?
Adem
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB Coder 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!