Resample Incorrect Assumption During Codegen.
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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?
0 commentaires
Réponses (1)
Darshan Ramakant Bhat
le 29 Jan 2021
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.
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!