Determine if script will crash due to Read-Only model workspace
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a script which can be called either from a block's mask parameters being changed, or from the same block's "copyfcn" callback. For the most part this works well, as the same script which updates the block based on mask parameters is run when a newer version of the block's template is copied in. However, I am having trouble with one part of my script which interacts with a variable in the model workspace.
When this script is run from the mask parameter, it works. But when it is run during the model's initialization, the model workspace is read-only, and my interaction with the modelworkspace variable makes my script crash. I know I can see which variables are in the modelworkspace with the "who" property, but to make this work I also need to know the size of the variables, and I can't figure out a way to get that information without using "evalin", which crashes with a read-only workspace.
This part of the script doesn't necessarily need to run as the model initializes, so if I could detect model run state or modelworkspace read-only state, I could add an "if" condition around the offending part of my script, but I can't find a way to detect this either. I try to avoid using "try" lines in my scripts. Is there any other way to do this?
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Programmatic Model Editing dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!