How to Initialise variables for simulink's matlab function block?
Afficher commentaires plus anciens
I using matlab R2010b matlab. In simulink I am not able to initialize the variables I want to use in 'matlab function block, I also used Preloadfcn callback as: set_param('mymodel/Test', 'Fish_rugg', loadvar);
my loadvar.m contains: time =0; I am using a matlab function block where I am updating value of variable 'time'.Now when I open my model 'Fish_rugg' and run it.Although my time is being initialised and also showing in workspace but it is showing error 'undefined variable 'time' first usage of variable define its class.I am not able to understand what is the problem in matlab function block that it is not using workspace variable.
Any help in this context will be greatly appreciable.
Réponses (3)
MAYANK JHA
le 29 Mar 2015
1 vote
hi, use the persistent functionality. refer here http://fr.mathworks.com/help/simulink/ug/defining-and-initializing-persistent-variables.html
1 commentaire
Alexis Artuso
le 10 Juin 2016
Hi MAYANK JHA,
I had the same problem and I am very happy to see your answer.
Thanks a lot,
Alexis
Fangjun Jiang
le 24 Sep 2011
Modifié(e) : John Kelly
le 4 Juin 2014
0 votes
Nicy Scaria
le 13 Fév 2019
0 votes
hi, I couldn't find the link given above. Is it deleted?
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!