The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [variable]

Questions on the use or manipulation of Mathematica variables (i.e. names associated with a changeable value). Use [variable-definitions] or [assignment] for questions on variable context localization, or assignment.

Filter by
Sorted by
Tagged with
23
votes
5answers
4k views

Extracting variables from an expression

I'm looking for a way to extract a list of variables from an expression, for example with an input like: ...
10
votes
6answers
894 views

Generate list of strings from a list of assigned variables

How do I generate a list of strings from a list of assigned variables? E.g. convert ...
14
votes
3answers
361 views

For any symbol, how can I get the full context-qualified name of the symbol as a string?

I'd like to have a function, whether built-in or not, that when given a symbol, whether bound to a value or not, returns a string giving the context and name of the symbol. Example: ...
1
vote
1answer
818 views

How to use Table to assign values to variables in a list?

I'm trying to do the following: R = {a, b, c, d, e, f, g, h, i}; Table[R[[n]] = RandomInteger[{0, 20}], {n, 1, Length[R]}] My intention is to assign a random ...
1
vote
2answers
912 views

Get all variables in an expression with Variables[] [duplicate]

"ϕ" <> "1"; Variables[%] Exp["ϕ" <> "1"]; Variables[%] Exp[Subscript[ϕ, 1]]; Variables[%] Say I have lots of variables used for construct an ...
4
votes
2answers
5k views

Using Array Elements as Function Arguments

Suppose I have an array p = {a,b,c,d} and a function f that takes a variable number of arguments. I want to evaluate ...
9
votes
1answer
1k views

What is and isn't a valid variable specification for Manipulate?

I have an expression whose terms have arguments (representing subscripts), like this: myExpr = A[0] + V[1,T] I would like to put it inside a ...
3
votes
2answers
344 views

Combining Multiple Lists

Let's say I have 4 lists: list1 = {a,b,c,d}; list2 = {e,f,g,h}; list3 = {i,j,k,l}; list4 = {m,n,o,p}; I can combine them using Join ...
17
votes
2answers
333 views

When to name a variable with $

There are some symbols in the Wolfram Language that start with $, including $Abort, ...
9
votes
1answer
582 views

Why does one of my Manipulate integer variables get turned into a real?

Bug introduced in 9.0 or earlier and persisting through 11.0.1 or later I'm developing code for manipulating graphs. Spot the difference in the 2 Manipulates below: ...
6
votes
5answers
944 views

Checking if all the variables are present in the defined function

I want to check if a user input the function with all the specified variables or not. For that I choose the replace variables with some values and check for if the result is a number or not via a ...
4
votes
2answers
145 views

How to find variables set through Get[“/some/path/dump.mx”]? [duplicate]

(NB: I could not find any good tags for this post. Please feel free to add better ones.) Suppose that the file /some/path/dump.mx was generated during an earlier ...
2
votes
1answer
68 views

Relabeling and matching variables (in MultiplicationTable)

Suppose we have a set of data given here as the multiplication table of 8 elements labeled {1,2,3,4,9,10,11,12}: $$ \begin{array}{cccccccc} 1 & 2 & 3 & 4 & 9 & 10 & 11 & ...
7
votes
2answers
247 views

Apply ToString to a list of variables [duplicate]

I have data1 = {1, 1}; data2 = {2, 2}; datalist = {data1, data2}; I want to create a string list based on the variable names inside ...
7
votes
2answers
1k views

Display variable name instead of value

Is there a way to display the variable name instead of its value? for example, I need something likevarname = 1; function[varname]; and the output is ...
6
votes
2answers
260 views

Want to return name of last defined variable without explicitly naming it

Suppose I have this code: dec = 7.1 + 6.6 + 27.2 + 66.5 jan = 7.1 + 6.6 + 27.2 + 66.5 + 65.7 feb = 7.1 + 6.6 + 27.2 + 66.5 + 65.7 + 69.7 And I want MMA to return:...
5
votes
1answer
220 views

An alternative to subscripts?

Are there any good alternatives to using subscripts to keep track of and uniquely identify many variables? I know that subscripted variables behave badly. Thanks!
5
votes
1answer
650 views

How to re-assign values to a List of variables?

The accepted Answer to this similar Question can only be used one time, so it's not suitable for my problem. I do high-dimensional calculations for which I need to make lists of variables, like so: <...
1
vote
2answers
1k views

Pass the list of variables into function to change their values

I'm new to Mathematica, so I don't really know, how do what I want, and I don't even know how to google it. Doing one Mathematica task for my supervisor, I faced the following problem. I need to ...
1
vote
2answers
348 views

Solve an equation with specific domain?

How can I write a code in Mathematica to solve an equation with variable in specific domains? For instance, I want to write a code for ...
1
vote
2answers
239 views

Creating a List of Symbolized Indexed Variables

I am trying to creat a list of indexed variables (symbols) using the Notation package and Symbolize command. As an example, ...
1
vote
1answer
50 views

Using Variables[] as the argument of Plot[]

I want to use the Variables[] function to extract the name of the variable of a function, such that I can use it later, e.g. in a ...
0
votes
2answers
10k views

How to pass a list as function argument?

I have the following function lFreqPhylo[a_, Q_, b_, p_] := Sum[Log[freqFunction[r[[p]][[i]], L[[p]][[i]], a, Q, b, {i, 1, nbranches[[p]]}]; The objects L, r ...
0
votes
1answer
64 views

Table and FindRoot of a 2 variable function of x and t : cos(x + 3t)

I am trying implement mathematica commands: Table and FindRoot, of a 2 variable function <...
0
votes
1answer
69 views

List output as a variable within a forloop function changes

The above image shows my code. The graph plots my results for two different values of the variable "guards" (1000 and 200), having first produced lists of these figures. What I want is for mathematica ...
0
votes
0answers
43 views

Symbol-handling, force-replace instanced variables within functions! [duplicate]

Currently I am stuck with the issue of renaming an instanced variable like r1$23314 to a global one. This issue arises as I need to use a "localizeAll" Module in ...