codegeneration array out of bounds check
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Bernhard Baier
le 25 Fév 2019
Réponse apportée : Krishna Zanwar
le 28 Fév 2019
Hi there,
I'm using the Simulink CodeGeneration to generate C-Code from a simple test Model:
![SimulinkTestModell.PNG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/205821/SimulinkTestModell.png)
The Counter is a 4-Bit counter and the Matlab function is defined as written below:
function y = fcn(u)
persistent fkt;
if isempty(fkt)
fkt = single([1 0.7 0.5 0.3 0.2 0.1]);
end
y = fkt(u);
During the Simulation of this model there is the correct error displayed that the array index 7 is out of Bounds. But if I use the CodeGeneration to generate C Code from this SubSystem the code just get's generated without an error.
The Question would now be ift there is a possibility during the CodeGeneration to check if array indexes could get out of bounds without having to simulate the Model first? The Array out of Bounds Parameter for the CodeGeneration is active but does not apply to this error.
This model is only a simple demonstration of an error occuring in a much more complex model. But since the other Model uses Hardware Inputs to generate many of it's control variables it is not easily to simulate.
0 commentaires
Réponse acceptée
Krishna Zanwar
le 28 Fév 2019
Hey Bernhard,
Simulink does not support checking out of bound array possibility during code generation.
You can run Simulnk Design Verification on the model to get these errors.
Or you can test the index inside your function block and get the output.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Verification, Validation, and Test dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!