Error occurred during compilation in the Simulink project 'Track Point Target in Dense Clutter Using GM-PHD Tracker'

1 view (last 30 days)
Hello,
In the Simulink project 'TrackPointTargetsInDenseClutterSimulinkExample', I changed the 'Simulate using' parameter in the Probability Hypothesis Density Tracker bloock from 'Interpreted Execution' to 'code genetation' and then ran the simulation. However, the following error occured during compilation:
An error occurred in the block 'TrackPointTargetsInDenseClutterSimulinkExample/Probability Hypothesis Density Tracker' during compile.
Caused by:
Simulink detected an error
'For code generation, str2func does not support anonymous function character vectors.'.
The error occurred for MATLAB System block 'TrackPointTargetsInDenseClutterSimulinkExample/Probability Hypothesis Density Tracker'. See line 887, column 37 in file 'C:\Program Files\MATLAB\R2023a\toolbox\fusion\fusion\trackingSensorConfiguration.m'. The error was detected during code generation phase.
Start code generation report.
To prevent this error, use one of the following:
* Modify the System object to avoid code that does not support code generation.
* Change 'Simulate using' parameter to 'Interpreted Execution'.
I changed the 'Simulate using' parameter back to 'Interpreted Execution' , but I encountered the same problem when using embedder coder for code generation.

Accepted Answer

Prashant Arora
Prashant Arora on 8 May 2023
Hi Lechi,
The reason for this error is the use of an anonymous function as a parameter of the PHD tracker block. Simulink does not support this.
This anonymous function is specified through the "Sensor Configurations" parameter of the block as the variable "config". Notice that "config" variable is a struct, which has a field "SensorTransformFcn". This field is currently set to @(x,params)x - which is an anonymous function.
To workaround this issue, use the following steps.
  1. Convert the anonymous function to a regular function on the path. This is replicating the SensorTransformFcn currently used in the example.
function x = transformFcn(x, params)
% Nothing to do
end
2. Specify the new function on the "config" variable using a character vector.
config.SensorTransformFcn = 'transformFcn'
With these two changes, you should be able to run the block in Code Generation mode.
Hope this helps. Please feel free to follow up here if this doesn't resolve your issue.
Thanks,
Prashant

More Answers (0)

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!