Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How to define local variables and constants in mathematica

  1. Dec 2, 2011 #1
    hi
    suppose i run Two notebook and in each of them i have matrix A and Constant B and a function C
    in each notebook these things have the same name.
    if in notebook 1 i assign B=10 then in notebook 2 B is 10 too , which is not my desire.
    how can i define these constants and matrices and functions so that they are not affect each other in each notebook.
    i do not want to rename one of these entities.

    thanks
     
  2. jcsd
  3. Dec 2, 2011 #2
  4. Dec 3, 2011 #3
    You can handle this behaviour using Contexts. Under the Evaluation menu, choose "Notebook's Default Context" > "Unique to This Notebook".

    Now each notebook will be using different name spaces, and the variables won't clash.
     
  5. Dec 7, 2011 #4
    thanks
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook