Resample Incorrect Assumption During Codegen.

조회 수: 5 (최근 30일)
Andrew Frock
Andrew Frock 2021년 1월 28일
답변: Darshan Ramakant Bhat 2021년 1월 29일
The resample function is using the incorrect variant when generating code.
My entrypoint function looks something like this:
function outputs = my_foo(input_struct)
% resample
[y,ty]=resample(input_struct.x, input_struct.tx, 1/5);
%rest of my function
end
And my coder config looks something like
cfg = coder.config('mex');
input_struct.x = coder.typeof(double(0), [1 inf]);
input_struct.tx = coder.typeof(double(0), [1 inf]);
struct_type = coder.typeof(input_struct)
spec = { ...
'my_foo' '-args' {struct_type} ...
}
codegen('-config', cfg, spec{:})
When run, this produces an error on the resample line saying "Expected Q to be integer-valued." This indicates that the wrong version of the the resample function is being used for code generation.
Resample should be using the "[y,ty] = resample(x,tx,___)" version, but it appears to be trying to use the [y,b] = resample(x,p,q,___) version.
However, when I replace my struct definition with
input_struct.x = zeros(1, 10);
input_struct.tx = zeros(1, 10);
struct_type = coder.typeof(input_struct)
The build is fine, and the mex function does produce the same output as my matlab function.
So my question is this, is there any way to force the codegen to use the correct resample version if I know my input type is going to use vectors of length at least 10?

답변 (1개)

Darshan Ramakant Bhat
Darshan Ramakant Bhat 2021년 1월 29일
Thanks for the detailed description and reproduction steps.
This looks like a bug in the codegen support for this function. I have made an internal note to investigate the issue. Please continue with the current workaround that you have figured out.
I will post here if we find a better workaround for this issue after our investigation.

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by