Error using assignin in a nested m function
Mostra commenti meno recenti
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.
Risposta accettata
Più risposte (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 Commento
Steven Lord
il 14 Nov 2025
Categorie
Scopri di più su Symbolic Variables, Expressions, Functions, and Settings in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!