Questions tagged [clear]
Clearing symbol values, removing symbols from memory and general garbage collection.
60
questions
0
votes
0
answers
36
views
How can I prevent functions and variables from being automatically cleared when I close Mathematica? [duplicate]
The following happens with every notebook I make:
I define functions and variables.
When I quit Mathematica and reopen the notebook, all of those definitions have been cleared. The functions and ...
3
votes
1
answer
80
views
How does one clear the value of a subs variable? [closed]
I saw the topics here, but it's not clear at all how to clear variables with sub.
Ideas?
Btw, does anybody know why Mathematica won't give me the numerical value of the 4-th zeta function derivative ...
1
vote
1
answer
47
views
How to clear a selection of definitions from UpValues?
I'm trying to set up a bunch of 2D points using UpSet that I am going to use later for building lines and graphs.
...
0
votes
1
answer
89
views
How to clear this variable [duplicate]
I can not clear this variable.
How to clear?
1
vote
1
answer
50
views
ClearAll required twice on a symbol with SyntaxInformation
SyntaxInformation[f] = {"ArgumentsPattern" -> {}};
f[] := 0;
After one ClearAll[f] or ...
1
vote
1
answer
117
views
How to Unprotect and Clear the E constant?
By default, E is used to represent the Euler's number in Mathematica.
I need the variable E to behave just like other undefined variables in my code. When I run the commands
...
0
votes
1
answer
44
views
All definitions are cleared when I reopen my file [duplicate]
I just started getting into mathematica and have the problem that whenever I save and reopen my .nb file, all functions and variables are cleared and I need to shift+enter every cell again to continue ...
1
vote
2
answers
141
views
'Do' loop acting on a global variable
I need a code that will allow me to alter a matrix (a global variable) iteratively using a function update (which depends on ...
0
votes
0
answers
92
views
Question about Clear function
I have a script starting with Clear ["r*", "data*", "file*"]. Does this clear all variables starting with "r" or "data"or "file"? Also, I ...
1
vote
1
answer
110
views
Setting a function equal to another function then Clearing the latter
I have a loop in which several values of a function are computed, depending on the values for that function that were computed in the previous iteration of the loop. This could be implemented ...
10
votes
1
answer
248
views
How to clear all definitions matching f[1, ...] but not f[2, ...]?
I would like to clear all definitions of the form f[1,...] in such a way that f[2,...] remain unaffected.
The two methods I know ...
6
votes
1
answer
106
views
Clearing ::usage message
After having assigned the usage message to f using
ClearAll@f;
f::usage=ToString@RandomInteger@{10^10,10^11};
the ...
1
vote
1
answer
127
views
How to clear all variables? [closed]
I have noticed that the old trick of using:
ClearAll["Global`*"]
does not appear to work anymore. It does not clear the values of any of my variables. I assume ...
4
votes
4
answers
181
views
Is it possible to create lookups on temporary symbols that still allow the symbols to be automatically removed?
Is there some way to create lookups keyed on Temporary symbols that somehow avoid the referencing of the Temporary symbols, ...
1
vote
0
answers
222
views
How to clear all subscripted variables? [duplicate]
I have the following variable:
Subscript[n, 0 ] = 12 (\[Sigma] L^2)/(e h^2)
If I now do:
ClearAll["Global`*"]
And then ...
26
votes
4
answers
943
views
Different strategies to get a clean Kernel. Quit, Exit, ClearAll, Remove, CleanSlate?
Often new users face problems with lingering definitions that, if unaware, may cause unexpected and frustrating behaviour.
There are several answers that illustrate different aspects of the solution, ...
2
votes
2
answers
510
views
Clear variables inside Module
I have a function that uses Module. The function takes as input a .csv that can have as many columns as it wishes to, and it ...
4
votes
1
answer
103
views
ThrowAway Environment and Scoping
I want to be able to Get a .wl file. Run some functions (who will do their job working on some separate files that are being written away). And then return to some clean slate so that I can repeat ...
-1
votes
1
answer
233
views
meaning of variable equal dot [closed]
I came across a program which I have written in a simplified form.
For[i=1,i<100, i=i+1;
func = a x^i;
func=.
];
What is purpose of "func=."?
0
votes
2
answers
256
views
How to 'unassign' variables used for PlotPoints, which subsequently print as e.g. Charting`Private`pvar$727158
I have a table of four insoluble equations, fceq, in terms of unassigned variables,
Subscript[fc, i], Subscript[μ, i].
I am using contour plots to visualise ...
10
votes
1
answer
91
views
Why ClearAll[n] does not clear effect of NumericQ[n]=True
To solve some PDE, I have to set NumericQ[n]=True on some symbol to get a solution, else Mathematica will not solve it.
When I tried ...
4
votes
3
answers
132
views
Apply Clear puzzle
This is OK
foo=1; bar=2;
Clear[foo,bar]
But this is not
foo=1; bar=2;
Clear@@{foo,bar}
Clear::ssym: 1 is not a symbol.
...
1
vote
0
answers
44
views
Is ClearAttributes built-in functon work in current cell only?
I have a question. Is ClearAttributes the built-in functon work in current cell only? This is my code:
In first cell:
Set[a, 6]
In second cell:
...
5
votes
1
answer
201
views
Clear a symbol from the kernel
I have a code that works over lists like
S0; (*initial list*)
S1=f[S0];
S2=g[S1];
S3=f[S2];
S4=f[S3];
.
.
.
where f and ...
1
vote
1
answer
190
views
Is it possible to Clear all variables defined in a given cell?
Suppose I defined a number of variables in a cell, in the Notebook interface. I know the number of this cell (In[296], for example). Is there a way to clear all the ...
3
votes
2
answers
74
views
ClearAll except a data table
How can I ClearAll variables and tables, except a table of data? Suppose the data table is WRR.
...
0
votes
2
answers
119
views
clear value from a bunch of symbols
I have a bunch of symbols which are collected as a list inside a variable within a bit of code e.g.
a=1;b=2;
par={a,b};
I want to clear the values of both ...
36
votes
2
answers
1k
views
How do I disable the stack tracing feature in Mathematica 11?
Bug was introduced in 11.0 and persisting through 11.1
It looks like the Mathematica 11 stack tracing feature (see red ellipsis in front of any warning message) prevents the garbage collector from ...
0
votes
0
answers
89
views
Calling Clear within a function [duplicate]
I want to create a function that when it is called clears the value of a parameter.
For example I want to keep the value of a parameter and then clear its valueby calling a function:
...
31
votes
3
answers
796
views
Why does removing a function and defining it on the same line not work?
Why do the two pieces of code below yield rather different results? The only difference is that in the first one the function definition is in the same line as the ...
3
votes
1
answer
509
views
How to "clear" the downvalues of a subscripted variable?
I have a function that sets certain subscripts of the symbol aa as in the following example:
...
0
votes
0
answers
49
views
Deleting variable assignments in a sub-notebook which is called from my main notebook
I have two notebooks; one main notebook which calls another notebook several times in a loop. I want to delete the assignments of variables in the sub-notebook which is called from the main one.
...
14
votes
2
answers
639
views
Good clearing practices
I have been using Mathematica for about 2 years and I'm pretty ok to write and optimize my code. Wanting to improve my practice, I often look at code examples. However, I can not determine if there is ...
16
votes
2
answers
371
views
Global context seems to be shared between kernels when using Clear?
I am trying to understand the following behaviour, and determine if it's a bug in Mathematica 10. I am using Mathematica 10.3, and can't reproduce this behaviour under Mathematica 9. The test outlined ...
4
votes
1
answer
305
views
Error given by the Clear function
I'm trying to clear out some variables that I've previously used, so that I can use them again. I tried this in a different notebook and it worked, however, now, a command like :
...
3
votes
0
answers
47
views
Context is not clearable and does not reload [closed]
I'm just going crazy with Mathematica Contexts as they absolute do not work as intended.
Simple Example:
Begin["TEST`"]
Hello[s_]:=s
Bye[s_]:=s
End[]
Now using ...
10
votes
2
answers
24k
views
How to clear everything in Mathematica? [duplicate]
I am a new user. According to a documentation,
Clear["context`*"] clears all symbols in a particular context.
I want to clear everything (functions, variables, etc..)
After I use the above command, ...
2
votes
2
answers
185
views
Partial reload of definitions from package
In order to keep my code modular, I have defined some functions in "Foo.wl" file, which I source with Needs["Foo`"].
When I modify a single function in Foo, I quit ...
2
votes
1
answer
2k
views
How to Clear derivative definitions?
I can't find a Clear or ClearAll command that gets rid of Derivative definitions I created. this code:
...
1
vote
1
answer
164
views
How to be sure I've cleaned up all prior definitions and assignments [duplicate]
Is there any general way besides restarting the kernel to make sure that nothing I've done earlier in a session will affect code I want to run now?
One book suggested running ...
7
votes
1
answer
273
views
Garbage collection for memoized functions on subkernels
I have a top-level function which operates on some data:
findBestIntegers[data_]:=ParallelMap[optimize,data]
which makes parallelized calls to an optimization ...
3
votes
1
answer
5k
views
Why my differential equations become True? [duplicate]
I've been trying to solve a system of nonlinear differential equation, but the conditions are a bit weird.
Two of the differentials equate to the same equation, but have different boundary ...
1
vote
1
answer
106
views
Do I need to clear all definitions whenever I experiment with new parameter values?
Do I have to clear all my definitions whenever I experiment with different parameter values for my model? For example, I have a simple model as follows:
...
4
votes
2
answers
234
views
Unset while running recursion
I am trying to run a recursive definition while at the same time clearing previously found values, so my memory is not completely consumed. I found this: How to clear parts of a memoized function? ...
24
votes
2
answers
7k
views
Error entering equation in DSolve
I entered a command incorrectly as follows:
DSolve[{y'[x]=y[x]},y[x],x]
I am now experiencing:
...
5
votes
1
answer
368
views
Remove Removed From Output
How might I remove Removed[..] symbols from the output of an expression?
For example
Clear[b]; b := Sin[a + a]; Remove[a];
b
...
9
votes
1
answer
3k
views
Clear and Unset doesn't free memory
Example: Try this example only if you have > 4G ram
d = 2000;
f[x_, y_, d_] =
Sum[Subscript[a, i, j]*x^i*y^j,
{i, 0, d - 1}, {j, 0, d - i}];
Then
...
8
votes
2
answers
637
views
ClearAll["Global`*"] stops working with Context set to 'unique to this Notebook'
I just changed my default notebook context to 'unique to this Notebook' so that variables don't roll across numerous open notebooks. Doing this, however, made the command ClearAll["Global*"] stop ...
10
votes
1
answer
2k
views
ClearAll just for current notebook
So in my search to fine tune Mathematica to what works for me, I found a nice setting that helps separate variable declaration between notebooks. Under Global Preferences, searching for CellContext ...
35
votes
3
answers
3k
views
How to clear parts of a memoized function?
I have a function of two variables, e.g.:
f[a_, b_] := f[a, b] = something f[a - 1, b - 1] etc
With the above code I used the concept of memoization to speed up ...