Questions tagged [scoping]
Questions on Mathematica's scoping constructs (Block, Module, With, etc.)
589 questions
1
vote
4
answers
255
views
`With` with auto-generated local variables
The strange goal
I want to do something like this
...
0
votes
0
answers
28
views
Symbols in Block not cleared [duplicate]
The symbols X1, X2, X3, mu, and M already have values as below. The goal is to temporarily clear these variables, perform symbolic calculations with these symbols, ...
2
votes
2
answers
226
views
Plot with local variables in Module[]: module or no module?
I need to draw sth using Plot (example below). I prefer using local variables in Module so that variables don't interfere others ...
4
votes
1
answer
216
views
is it possible to break a module into several sections
There are certain reasons to write certain variables and expressions in different
adjacent sections or subsections. Is it possible to span a module over sections or subsections like this to separate ...
0
votes
1
answer
130
views
Why did my output take so many images and still look strange? [closed]
This is my code:
...
0
votes
1
answer
132
views
How can I plot the graph of Q versus V? [closed]
I want to plot the graph of Q versus V, but my code doesn't work, and the output for Q and V are both empty. Could you help me identify the problem?
This is my code:
...
3
votes
2
answers
206
views
Unexpected behaviour of Module and/or DynamicModule
The following two functions are identical, apart from the fact that the first one uses Module and the second oneDynamicModule.
<...
2
votes
4
answers
182
views
Saving and recalling information in Manipulate using localized parameters
I want to allow users to enter some parametrized plots, using the variable t. I want the variable t to be localized to a ...
5
votes
2
answers
400
views
Local indexed variables in With
I need to use local indexed variables inside With but it is not allowed, the same for Block and ...
0
votes
0
answers
75
views
Unprotect/Clear only within a local context
I'm working on a project, and I want to Unprotect and ClearAll the properties of NonCommutativeMultiply, but only within a local ...
3
votes
0
answers
68
views
Help understanding why Module variables (e.g. esoteric) sometimes persist as scoped (esoteric$) in the name space, and sometimes not
This part will print the change:
nomos = Names["Global`*"];
Print @ Complement[Names["Global`*"],nomos];
And in between you can run one of ...
2
votes
1
answer
196
views
Should large data be localized in DynamicModule, and why does wrapping Module around it cause syntax warnings?
Apologies for the long question. The question is more pedagogical than practical.
I am trying to improve the performance and usability of a simulation and its visualization. The root of the question ...
0
votes
1
answer
135
views
Symbol in Global Context but List in Module and Block? [duplicate]
Can someone explain the principles underlying the following behavior.
I define the list testD, and then use a Do loop to change values in the list (I realize there are smarter ways but they don't fit ...
0
votes
2
answers
167
views
Local functions of global variables in Blocks
I am very confused by the difference in behaviour of the following two functions:
...
2
votes
1
answer
155
views
Evaluate section in a loop
I would like to evaluate a section several times for different values of some variables. I can evaluate it once with a simple command, but not in a loop.
To evaluate it only once, this code works
<...