title: MATLAB symbolic variables couldn't be used in nested function
body: <p>I have a MATLAB function to solve a Inertia Tensor , and I have a nested function in my program . All the variables in it are symbolics but it told me </p>
  
  <p>“Error using assignin: Attempt to add ”x“ to a static workspace”</p>
  
  <p>and I don't understand why this happens . Here is my test.m code:</p>
  
  <hr>
  
  <pre><code>function test
  
  syms x y z 
  f=x
  f1=f+1
  f2=f1^2
      function r=test2        
          r=f2^3;
      end
  f3=test2
  end
  </code></pre>
  
  <hr>
  
  <p>After searching this web-forum I have found some answers . But at the same time I just don't understand it </p>
  
  <p>Andrew Janke explianed it like this : <strong>While syms A may look like a static variable declaration, it isn't. It's just a regular function call. It's using Matlab's "command" invocation style to look like syntax, but it's really equivalent to syms('a', 'b', 'c').</strong>
  on this page : <a href="https://stackoverflow.com/questions/17105493/matlab-error-using-assignin-attempt-to-add-c-to-a-static-workspace">Matlab: &quot;Error using assignin: Attempt to add &quot;c&quot; to a static workspace&quot;</a></p>
  
  <p>what does static variable mean ? </p>
  
  <p>I also search the HELP doc and it said :<strong>In functions and scripts, do not use syms to create symbolic variables with the same names as MATLAB® functions. For these names MATLAB does not create symbolic variables, but keeps the names assigned to the functions.</strong> </p>
  
  <p>I only know <code>syms x</code> to create a symbolic variable in the workspace but why does the documentation say MATLAB does not create ?</p>