Why do I get a "Failed to compute constant value for nontunable property" error while generating code using a MATLAB System Object?

9 views (last 30 days)

I have a function that defines a "trackerGNN" system object and want to generate code for it

function [output] = trackerModule2(input, allTracks)
persistent GNN
save('Tracksave1.mat','input','allTracks');
if isempty(GNN)
GNN = trackerGNN('AssignmentThreshold',input.AssignmentThreshold,...
'MaxNumSensors', input.numSensors,...
'TrackLogic','Score',...
'ConfirmationThreshold', input.ConfirmationThreshold,...
'DeletionThreshold', input.DeletionThreshold,...
'DetectionProbability',input.DetectionProbability,...
'FalseAlarmRate', input.FalseAlarmRate,...
'Volume', input.Volume,...
'Beta',input.Beta); %Toolbox specific
end
...
end
However, when I try to generate code from the function, I receive the following error:

>> codegen trackerModule2.m -args {input, allTracks}??? Failed to compute constant value for nontunable property 'AssignmentThreshold'. In code generation, nontunable properties can
only be assigned constant values.
How can I resolve this error?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 22 Jul 2024
MATLAB Coder is limited to only adding nontunable parameters for system objects like 'trackerGNN' by creating them as compile time constants.
To achieve this, please use the "coder.Constant" class to use the argument values as compile time constants like so:
>> codegen trackerModule2.m -args {coder.Constant(input), allTracks}

More Answers (0)

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!