Variable Size Array bounds when compiling Simulink Model not working

2 vues (au cours des 30 derniers jours)
Hello guys,
I got the following problem: I am currently trying to compile a Simulink Model using Blocks from the Robotic System Toolbox to C++. The compiler struggles when using variable size arrays in embedded matlab blocks.
The function is very simple and looks like the following:
function TWaypoints = ellipse (numWaypoints)
coder.varsize('TWaypoints', [3 30]);
TWaypoints = zeros(3,numWaypoints);
end
Even I defined the bounds of the array, I still receive the error message:
Computed maximum size is not bounded. Static memory allocation requires all sizes to be bounded. The computed size is [3 x :?]. More information
Function 'ellipse calculation ' (#86.189.210), line 13, column 14: "zeros(3,numWaypoints)" Launch diagnostic report.
I dont't really know what I am missing and couldn't find anything helpful in similar questions about compiling Simulink models with variable-size arrays, so your help would be greatly appreciated :)

Réponse acceptée

Alok Nimrani
Alok Nimrani le 10 Juil 2018
Hello Jan-Felix Klein,
The error message is received because by default, a MATLAB Function block input signal or output signal is not variable-size. For a MATLAB Function block, you need to explicitly define the sizes and the upper bound in order to use the variable size signals. Go to the "Edit Data" option of the MATLAB Function from the Editor toolstrip and check the variable size box. Also, make sure you have specified upper bounds as described in the documentation:
Please note that this upper bound cannot be changed within the MATLAB function since dynamic memory allocation is not allowed for input and output signals as described in the following documentations:
I hope the above information is useful to you.
Thanks.
  1 commentaire
Jan-Felix Klein
Jan-Felix Klein le 12 Juil 2018
Thank you for the useful links, what I forgot was to activate the Dynamic Memory Allocation

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by