title: Matlab: "Error using assignin: Attempt to add "c" to a static workspace"
body: <p>I have the following piece of function definition (test code):</p>
  
  <pre><code>function [X,Y,Z] = test(x,y,z)
  
  syms a b c;
  a = b + c;   % This is where it gets wrong
  
  X=x;
  Y=y;
  Z=z;
  
  keyboard
  
  % nested functions
      function y = fun1(t,x)
          y=t+x;
      end
  
      function res = bvpbc(y0,yT)
         res= y0+yT;
      end
  
  end
  </code></pre>
  
  <p>Basically, I have some nested functions within the <code>test</code> function, where I declared some symbolic variables <code>a</code>, <code>b</code> and <code>c</code>. However, when I run the function by typing</p>
  
  <p><code>test(1,1,1)</code></p>
  
  <p>there is always this error message:</p>
  
  <pre><code>Error using assignin
  Attempt to add "b" to a static workspace.
   See MATLAB Programming, Restrictions on Assigning to
   Variables for details.
  
  Error in syms (line 66)
          assignin('caller',x,sym(x));
  
  Error in test (line 3)
      syms a b c;
  </code></pre>
  
  <p>It seems to be something wrong with the symbolic declarations, but I don't understand why. How can I fix it?</p>
  
  <p>Thank you!</p>
  
  <p><strong>EDIT:</strong> In addition, whenever I remove the two nested functions, the <code>test</code> function will work just fine. </p>