Questions on assigning and unassigning definitions to names that represent them, including issues raised by context and localization. Use tag [assignment] for issues relating to Set versus SetDelayed.

learn more… | top users | synonyms

-1
votes
2answers
51 views

Module function corrupts string? [on hold]

I have the module who should replace some elements of a matrix with checkboxes ...
25
votes
5answers
11k views

How do I clear all user defined symbols?

Is there some way to do this other than going to Evaluation -> Quit kernel and firing a new one up?
0
votes
1answer
36 views

How to assign the array data to variables?

A very basic question but puzzled me for long time on how to assign array to variables. For instance, we have array {{t1,x1},{t2,x2}...{tn,xn}} how to assign the first element to variable t and ...
20
votes
2answers
2k views

How to define a global variable when giving each notebook its own Context?

I have restricted the context of my notebooks to each individual notebook. So variables in each notebook are local and are not seen in another notebook. But in two of my notebooks I have two ...
0
votes
0answers
8 views

Watching variables during Notebook work session [duplicate]

One feature that I have always wanted but could not find out if it was supported and that is to actively watch variables and their values while working in a Notebook session. In fact, there are two ...
4
votes
2answers
77 views

Injecting list of controls into manipulate

I am trying to program a method to manually move around graph vertices, and then output the new coordinates. I'd like to turn this into a function that can be called with a variable number of ...
1
vote
2answers
141 views

How to tell Mathematica that certain variables are real/imaginary, integer-valued, etc

I'm trying to expedite some quantum mechanical calculations by running them through Mathematica. Expectation values and stuff like that. When I say, for example, ...
0
votes
1answer
25 views

Variable as Difference of 2 Variables

I would like to evaluate a function based on the absolute difference of two variables. An example: g=5*x-5*x*y-5*y diff=x-y D[g,x] D[g,y] D[g,diff] I cannot find ...
3
votes
1answer
55 views

Defining a function that prints both the name and value of a variable defined locally within the calling function

To save time when debugging with Print statements, I'd like to define a function -- call it PrintVal -- that prints both the name and value of a variable defined locally within the calling function. ...
1
vote
1answer
77 views

How to form a variable from matrix elements

I have matrix with n rows and 2 columns, say m = {{x11, y12}, {x21, y22}, ..., {xn1, yn2}. Now, I want to form three new variables for example: ...
1
vote
0answers
97 views

How to create a complex variable from dated list values

Can anyone help me to construct a variable "PI" from values of variable x. Variable x represents a group of two time series rj and ri on equal dates(joined two dated lists with states).Variable x have ...
13
votes
1answer
296 views

Is garbage collection broken in version 10.0.0?

Bug introduced in 10.0.0 and fixed in 10.0.1 In version 10.0.0 under Windows I am observing the following behavior: ...
27
votes
2answers
1k views

Best practice of passing a large number of parameters to functions

I have a number of functions that all take a large number of parameters. I am wondering what is the best practice of passing these parameters to those functions. I could, of course, simply specify ...
2
votes
1answer
66 views

Equivalent command to the Maple indets command

This carries on the discussion here and here. I had mistaken Variable[] to give you ALL variables in an expression, but apparently, it is not meant for that. ...
0
votes
1answer
76 views

About Symbolize and Variables

I do believe this sort of similar questions had been asked many times, so I have read a LOT. For example this and this as well as many other related posts. But a glance at what my main question is ...
3
votes
1answer
74 views

Need some explanation of “Global`*”

When I start a new notebook, I enter Names["Global`*"] I get this {"list", "msgs", "rhs", "z"} Then I enter, ...
0
votes
0answers
15 views

SharedVariable in WebMathematica

How can I create a variable to be used and setted over all my WebMathematica kernels? Here is the case: Create a package with do data structure like: data = ...
0
votes
2answers
112 views

Variable Value as Range

Thank you for the help so far! I would like to assign +/i signs for the function and solution such as (+)(+)(-) and therefore (-). It is working for the first evaluation, λlower, but not for the ...
3
votes
2answers
126 views

Convert matrix rows into variables

Can anyone show me how to set all matrix rows to variables. For example, I have matrix w={{1,2,3},{3,2,1},{0,0,0}} and I need to set each matrix row to be separate ...
0
votes
0answers
39 views

Replacing variable names in a notebook

I am working on a code that simply imports and graphs a function. If I preset the directory I would have something that looks like this: ...
5
votes
3answers
143 views

Assign output of solve to variables [duplicate]

I have this input: Solve[x^2 + 3 x + 2 == 0, x] which gives this output: {{x -> -2}, {x -> -1}} I want the first x ...
11
votes
3answers
1k views

Elegant manipulation of the variables list

I have a list of global variables (some of them are indexed variables), for example: varsH = Hold[U0[1], U0[2], B0, V0[1], V0[2]] Or (if it is easier to handle) ...
2
votes
2answers
98 views

Local variables whose definitions depend on each other [duplicate]

Consider the following (pseudo-)function definition: f[l_] := Let[{ a = Length[l], b = First[l], c = b/a, }, c*10] So for ...
1
vote
3answers
74 views

Store matched variables

Edit: I am matching and replacing a particular expression. At the same time... I want to store matched variables for later use. I got it to work with messed up code involving ...
4
votes
4answers
461 views

How can I prevent Superscript from being interpreted as Power?

I have very strong desire to use superscript as the index of the variable. However, it looks like that the Mathematica automatically recognize the superscript as the power and I got message that my ...
1
vote
1answer
95 views

Solving equations with QuantityVariable

I'm trying to understand how to easily solve equations that use QuantityVariable. Why does this fail? ...
0
votes
1answer
31 views
6
votes
2answers
101 views

How to name a variable with the value of another variable?

A simple but very important (at least for me) question. In some languages for defining a variable, for example, we can do: i=10 "d"&i=30 So I have defined the variable d10, and... d10=30 ...
6
votes
4answers
523 views

Why do I see the error “only assignments to symbols are allowed” when using a Module and not otherwise?

When I type Remove["Global`*"] foo[] := Module[{Subscript[a, 1] = "x"}, 0]; foo[] I get the expected error "only assignments to symbols are allowed". I ...
0
votes
1answer
36 views

Reducing Output length by introducing new variables [duplicate]

I have outputs like "expression/(1+3*c^2) +anotherexpression/(1+3*c^2)" and so on. Is there any way to set 1/(1+3*c^2)=A where A is a new variable so that the output reads like ...
1
vote
0answers
71 views

specifying a list (vector) of arbitrary length

When trying to do symbolic calculations in mathematica involving a space of dimension n, which is arbitrary but fixed, I'd often like to work with vectors that have ...
4
votes
1answer
82 views
0
votes
1answer
57 views

Is there a command returning information about a particular object? [closed]

Suppose I have a variable var1, a function MyFunction, and a graphic SomePlot. I remember ...
4
votes
1answer
124 views

Multiple down-values with exactly the same lefthand side

I was working on an answer to this question, when I was sidetracked by what I bring up here. I wanted a function, which when given a string representing a binary number, would convert the string to a ...
0
votes
0answers
50 views

Coupled ODEs with boundary conditions - DSolve Error

I'm relatively new to mathematica and I can't find the error here. I suspect it has something to do with the fact that vx, vy, vz aren't blue on my mathematica - as in, they already have some assigned ...
1
vote
2answers
128 views

Define the square of a function [closed]

Is there any good way to define the square of a function in M9? Usually one can write e.g. f[z_] = 3*Sin[z] etc etc. But is it possible to define ...
1
vote
2answers
88 views

Using AddTo in a function

I want to create a function that will take a variable $x$ and reassign the value $x+2$ to $x$. So f[x_]:= x += 2 However: ...
0
votes
3answers
109 views

Identifying the symbol which has a specific value

I'm writing a program that will solve the value of 1 variable in a 4-variable equality equation, but the variable to be solved will depend on the user's input to the program. This is what I've come ...
1
vote
2answers
72 views

Calling variables with use of numbers in their names

I have got few huge matrices named by ascending numbers, e.g. x1, x2, x3,... and I need to do the same operation with all of them - to multiply their components, ...
2
votes
2answers
128 views

Using a variable for two different purposes

I want to name a bunch of tables after the OEIS entries which describe them. Is there any way to use these names for both the table name and the link at the same time? The second line uses the ...
2
votes
3answers
113 views

Extract memoized results in the form of a rule

Lets say I define a function f with memoization. Is there some way to extract the memoized values? For example, ...
2
votes
1answer
130 views

Define function that counts recursive fibonacci

If I write count=0; fib[0]:=(count=count+1; 0); fib[1]:=(count=count+1; 1); fib[n_] := (count = count+1; fib[n-2] + fib[n-1]); Then I can ...
0
votes
1answer
31 views

Indexed variable with alternatives

I have a["tree"] := "oak" a["flower"] := "rose" a["dog" | "cat"] := "animals" I want that the last definition of a behaves ...
4
votes
1answer
134 views

When to use indexed variables

Still learning the fundamentals of the language I would like to ask you what advantages there might be in writing something like: a[1] = 2; a[2] = 4; a[3] = "x"; ...
0
votes
1answer
63 views

How I can define a new function as a function argument?

I need to pass a function with t as independent variable as a function parameter and want to create a new function of the same through this provided the argument of another function. Here is my code. ...
0
votes
0answers
36 views

Can the value of a variable be made to persist between front end sessions? [duplicate]

For example, say I create a notebook with a cell a = 5 + 2 and then I close Mathematica, reopen the notebook, enter a new cell ...
3
votes
1answer
88 views

How to localize symbols on the right-hand side of Rule when using ReplaceAll?

I am frustrated by the following: {1, 2, 3.0} /. a_Integer -> a + 1 The a on the left side of the arrow is localized and ...
2
votes
1answer
47 views

Quoting definition explicitly

I'm trying to quote a definition using DownValues, OwnValues, etc. Everything seems to be fine, except for temporary symbols' ...
0
votes
2answers
47 views

how to define roots of an equation as a function? [closed]

I need to solve an equation depending on 3variables in only one variables and define the roots as a function of the remaining variables? I used some thing like that: ...