Error using assignin in a nested m function
Afficher commentaires plus anciens
Error using assignin
Attempt to add "q" to a static workspace.
Error in syms (line 283)
assignin('caller', x, xsym);
Error in mywork/myfunction (line 66)
syms a(t) q
This error occurs when running mywork.m but not myfunction alone.
Réponse acceptée
Plus de réponses (1)
Assignin is something you should generally try to avoid. It has many hazards.
In this case, where myfunction is nested in mywork, it should be especially unnecessary. Just pre-initiliaze q in mywork's workspace (e.g. set it to empty, []). Then, q will automatically be shared with myfunction's workspace as well, see Sharing Variables Between Parent and Nested Functions.
1 commentaire
Steven Lord
le 14 Nov 2025
Catégories
En savoir plus sur Symbolic Variables, Expressions, Functions, and Settings 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!