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
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 & ...
1
vote
1answer
63 views

Use Manipulate for a global variable

I do have a global variable called w1, which is used as a factor in a dataset, however I want to make this factor dynamic. ...
0
votes
1answer
55 views

How can I evaluate a function using the results of Reduce?

Can I use the output of reduce to define a variable in a function definition? In other words, can I somehow skip the step where I manually enter t:=2? ...
0
votes
0answers
42 views

assigning numerical values to variable

I have a csv data file, has two columns of data. First column denotes time (t) and the corresponding value in the second column is flow rate (f). I would like to assign these values to an array f[t], ...
0
votes
0answers
166 views

What are the valid symbol names for packages?

Regarding to the message: ...
1
vote
0answers
57 views

Execute a notebook with a changing variable

I have created a notebook with one fix variable that I want to run from 1 to 100. Every time the whole notebook (all cells) shall be executed for the given number. At the end of the notebook, it shall ...
0
votes
1answer
57 views

Issue with variable recognition

Why are the variables r,s,u,v identified differently in the definitions of F2,G1,G2?
1
vote
1answer
441 views

How to evaluate user-defined functions with variables?

I have an extremely simple question, but I couldn't find anything anywhere, maybe I didn't know what to search for, so feel free to mark it as duplicate if there is a duplicate. Let's say that I ...
0
votes
1answer
62 views

Create an array of independent variables of variable size, all dependent upon the same dependent variable

I have an array of variables that I've constructed, that all depend on time s ...
0
votes
2answers
50 views

How can I create a row matrices of large dimension by a code? [closed]

I am trying to figure out how to create a function that can create the row matrix pattern below. co = {{a1, a2, a3, a4, a5, a6, ...., a100}};
3
votes
0answers
457 views

Multiple variable assignment from a list

For example in Python, if we have a list of 3 elements, say ls = [1,2,3] and we want to assign a variable to each value (from left to right), one can do as follows: ...
3
votes
2answers
330 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 ...
0
votes
0answers
73 views

Is there in Mathematica something like class in Java or struct in C? [duplicate]

I am new to Mathematica and I am very impressed with its features. Although I don't understand how to do a simple thing: for example, I want to create few point variables (say a,b,c,d,e), each storing ...
0
votes
0answers
65 views

The conditions used in Sum or ParallelSum: Calling a function/variable

For some reason, I encounter a problem when doing the Sum and ParallelSum (or doing the Do or ParallelDo, e.g. such as the issue here), I figured that the potential cause of the problem can be ...
0
votes
0answers
19 views

Write vector with variables and calculate its norm in terms of the variables [duplicate]

I have a vector v defined as follows: v[x_] = {0.5, 0., x} I calculate its norm, and expect for it to be ...
0
votes
1answer
128 views

Solving an equation of two variables by looping over different values for one variable [closed]

I have a function: f[x_,y_]=x+y. I would like to loop over some values of x, and solve for y ...
1
vote
1answer
40 views

Numerically solving a system of three nonlinear equations by predefining functions [closed]

I have three functions of three variables, f1(x,y,z),f2(x,y,z), and f3(x,y,z), and I'm ...
6
votes
1answer
209 views

Tremendous bug using EstimatedDistribution (using NMinimize) in v8.0 and v10.2

Let's define F4 and estimate the distribution of the data: ...
2
votes
3answers
197 views

How to extract variables with time subscript and their coefficients

I have a expression of the following form: $$x_{t}=a_{0}+a_{1}x_{t-1}+a_{2}y_{t-2}$$ where $a$'s are just coefficients and anything with time subscript is a variable. I would like to have list of ...
0
votes
0answers
53 views

to reduce the unknowns of a set of equations with several symbolic coefficients, e.g. using the GroebnerBasis

I have a set of $4$ equations with $4$ unknowns $\theta_1$ to $\theta_4$, and would like to eliminate the number of unknowns, to get a smaller set of equations, e.g. $n$ equations with $n$ unknowns, ...
0
votes
0answers
378 views

Extract fit error from parameter table to use as a variable

Is there anyway to extract the fit error and store it in a variable. I have done something similar to use actual fit results as ...
0
votes
0answers
29 views

function restorage problem [duplicate]

Code below f[1, 1] = 1; f[1, 2] = 2; f[1] = Min[f[1, 1], f[1, 2]] Outputs 1 However, the desired output is ...
0
votes
1answer
39 views

Taking variables from string

In a mathematica operation I am getting the o/p say, 1->2. For the next step, I want to use these two numbers as variables, say take them as 1 = m and 2 = n. How can I do it.
1
vote
2answers
117 views

variable dimension table

(A very simplified version of my code:) How can I create a Table[] with a variable number of dimensions, e.g.: ...
1
vote
2answers
128 views

How to transform a series of scalar variables to a vector variable? [closed]

Say a function is set: a := Sum[b[i], {i, 8}] As can be seen that b[i] is a scalar variable. Now I want to transform the ...
2
votes
1answer
81 views

How to form list of all OwnValues of symbols in Global context? [duplicate]

How do I get the list of all OwnValues of symbols in the Global` context? All my attempts have failed because ...
2
votes
3answers
404 views

Assign an array of numbers to an array of variables

I have a huge array of variables like this. ...
3
votes
2answers
94 views

Treat 2 variable as 1

Is there anyway to treat two variable, that are a result of expansion, as one? To use Solve[] I can do ...
2
votes
3answers
206 views

Pure function within another function

I am writing a function along the lines of the following: func[basis_,coordinates_,vars_]:=Table[Function[vars,monomial]@@@coordinates,{monomial,basis}] The idea ...
0
votes
1answer
71 views

Solve trigonometric expression

Mathematica is not able to solve this expression : $Solve[ 2 e == h + r * sin[theta - q ] + b* sin [theta ] + e*cos[theta ] , theta]$ Solve::nsmet: This system cannot be solved with the methods ...
0
votes
1answer
392 views

Is it possible in mathematica to use dynamic names of variables [duplicate]

I have variables in my code following the following notation : theta12, theta13, theta14 etc.. I would check the values of all this variable so I could write an if condition for each theta but I ...
3
votes
0answers
48 views

Variable assignment/replacement issues

I have three questions about variable assignment. Module[{z}, z = y; p'[y] /. p -> Function[y, Evaluate[z]]] When I run the above code, it outputs 0. 1) If I ...
0
votes
0answers
45 views

Similar Variable Names

I have variables $X1,...,X10$ and $X1hat,..., X10hat$ in a system of equations. How can I refer to these variables in a summation? I am looking for something like: ...
4
votes
2answers
143 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 ...
1
vote
1answer
33 views

Substituting variables in only certain environments? [duplicate]

I was integrating a function and got something essentially like E^(mu beta) * (1/beta) There beta is defined as ...
2
votes
2answers
146 views

Separating variables in an expression

Given a non-polynomial expression such as: expr = x z Sin[x] Sin[y] and that we know that the variables are: var = {x,y,z} ...
1
vote
1answer
45 views

Unexpected behavior of Variables [duplicate]

I apologize in advance if this is a duplicate. Variables has a strange behavior when it encounters powers: ...
4
votes
1answer
163 views

Context inside Do[…]-loop

Consider the following code: Begin["mycontext`"]; myvar = 7; Print[Context[]]; Print[Context[myvar]]; End[]; with the output mycontext` mycontext` Now ...
0
votes
0answers
157 views

Colors of variable mathematica

Suppose that I have an equation which goes like this: x = 2; yp = 2; y_p= 2; a = x + yp + y_p; Usually, once the variable is defined it will be of blue color and ...
1
vote
1answer
50 views

Dealing with root powers of variable to some other power

In my code I keep coming across terms like this in the output $(w^3)^{\frac{1}{3}}$ that mathematica refuses to simplify. I have tried using a simplifying assumption such as $w\in\mathbb{R}$ or $\...
7
votes
2answers
245 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 ...
11
votes
2answers
462 views

Is there a convention on which name to use for a throwaway variable? (Like underscore in Python) [duplicate]

I would prefer to write {_, foo} = LongFunctionName[arg1, arg2] instead of foo = LongFunctionName[arg1, arg2][[2]] or ...
1
vote
1answer
90 views

How to find all up-value symbols related its object

Suppose I set a series up-value for a rectangle like: rectangle[long] ^= 10; rectangle[width] ^= 12; rectangle[height] ^= 28; How to find all of the symbol about ...
-1
votes
1answer
111 views

Symbolic representation of Class Conditional Probablity as a variable

What is the best way to a create a symbolic variable to represent Class Conditional Probability in Mathematica e.g. $p(A|B)$
2
votes
0answers
95 views

Is there an easy way to to collect a large number variables into a list or list of lists? [closed]

I have a large number of variables in a notebook from a data analysis routine, the results of which now need to be fed through a mathematical model and various items for visualization. For example, ...
2
votes
2answers
689 views

How to set variable from imported data

I have an excel file i would like to import as data in mathematica with 3 columns like below: Column 1: the nodal numbers Column 2: the values of mx Column 3: the value of mxy Once ive imported the ...
3
votes
3answers
500 views

Getting a list of variable names as strings via a function

This is a new twist of an earlier question about how to get variable names as strings from a function. I would like to have a function that returns a list of variable names, each being a string, from ...
1
vote
1answer
94 views

Is it possible to “escape” numbers so they can be used as a variable name? [closed]

I would like to be able to use numbers in the names of some of my variables, it's simply easier to read that typing TwoPointZero. Is this possible? Or is there an alternative to being able to define ...
1
vote
2answers
234 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, ...
0
votes
2answers
2k views

writing the expression for one variable in terms of another variable

I have a polynomial equation with 2 variables, lets say $x$ and $y$. For example: $x^2 + y^3 = 5$ And I want to write the above equation with $x$ on left side expressed in terms of $y$ on right side, ...