How do I use persistent variables in MATLAB Function Blocks?
Afficher commentaires plus anciens
I have a MATLAB function block that uses a persistent variable 'n' to calculate the output.
In my MATLAB function block I initialize persistent variable 'n' as 1 when the input to the MATLAB function block is 0, but I still get an error saying:
Persistent variable 'n' is undefined on some execution paths.
My MATLAB function block takes a counter as input, hence, the input is always 0 at the first time step which leads to initialization of 'n'.
Why am I getting this error and how do I get around it?
Please find a simple model which reproduces this issue.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Simulink Functions dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!