Reputation: 382
I use Matlab coder to generate C code of the following function:
function [out] = myresample(in)
out = resample(in,4644,1000,10);
end
and generate the code by codegen myresample -args {coder.typeof(0, [1 Inf]), 0} -config cfg
, where cfg = coder.config('lib')
, cfg.DynamicMemoryAllocation = 'AllVariableSizeArrays'
.
But it reports the error as:
??? The number of terms N must be constant.
I am confused why it is wrong. Interestingly, when I change the function to
function [out] = myresample(in)
out = resample(in,10,10,10);
end
it works.
I have found some links explaining how to generate code of resample
. But it seems not work for my case.
I use Matlab 2017b.
Thanks.
Upvotes: 2
Views: 330
Reputation: 1550
According to Matlab 2017b documentation:
C/C++ Code Generation: Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
C and C++ code generation for resample requires DSP System Toolbox™ software. The upsampling and downsampling factors must be specified as constants. Expressions or variables are allowed if their values do not change.
Variable-size inputs are not supported.
Here on your code, you have in
that is not limited in size.
in your function myresample
, you should try to specify a limitation. Something like:
limited_in = in(1:128);
out = resample(limited_in,4644,1000,10);
So the size of the inputs of resample
will always be constant.
Upvotes: 1