Questions tagged [variable-definitions]
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.
15
questions
3
votes
1
answer
80
views
Variable localisation in Table
I'm trying to understand Mathematica's behavior when creating a Table based on a given list of variables. I'm using a dummy variable to iterate through the list, and I want to make sure that ...
5
votes
2
answers
269
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 ...
1
vote
1
answer
31
views
Optimizing the assignment of variables to DateIntervals for large sets
I have a dataset of 17 time intervals with the form:
dataset1 = {{{1969, 7}, {1970, 2}}, {{1972, 4}, {1973, 4}},...}
The goal is to plot them with "...
1
vote
0
answers
59
views
Hermiticity of a matrix that depends on a symbol
Suppose I have a real number $x$, and I want to check the hermicity of the matrix $A=x\sigma_x$, here $\sigma_x$ is the Pauli matrix $\{\{0,1\},\{1,0\}\}$, I run the code
...
0
votes
2
answers
131
views
How to automatically extract all variables from a complete code block and place them into a list?
In the code for drawing 3D geometric figures, there are usually several variables related to points. How can one automatically extract all these variables from the complete drawing code and form them ...
2
votes
0
answers
59
views
Why do notebooks by default put symbols in Global context where they can collide with all other notebooks?
This default setting can cause subtle and difficult to find problems, such as inconsistent or incorrect answers when symbols, variables or functions in different notebooks have the same name. I speak ...
0
votes
1
answer
41
views
Defining Objects using a Table or Loop
Suppose I want to define weight[] on a list. For instance I want weight[a]:=3, weight[b]:=5, etc. I tried to do this using the ...
6
votes
1
answer
339
views
What is the difference between Clear and Remove?
I assume that there is difference between the commands Clear and Remove. But it seems to me that I am not aware of any caveats ...
1
vote
1
answer
70
views
Import all files in NotebookDirectory, store each list in a variable with the file name without extension
I have many files stored in the notebook directory, which are called "lista.dat", "listb.dat", ... I would like to import all of them and save them as variables called "lista&...
2
votes
2
answers
265
views
How to calculate a definite integral with a parameter
I am trying to calculate the following definite integral with the parameter H. So my result would like to be a analytical one with the parameter H. For example for the integral NIntegrate[ax, {x, 1, ...
0
votes
0
answers
48
views
Invalid variables error in SolveValues when using an array of variables
I was attempting to run some code similar to the simple example below.
...
0
votes
1
answer
77
views
How to set optional variables in Function?
When using Function, is it possible to set specific arguments to be optional? For instance, in
f = Function[{x, y}, x + y];
Can ...
0
votes
1
answer
66
views
Defining a function of a variable through another intermediate variable
The following is a really simplified version of what I'm trying to do. I have a variable fn defined in terms some other variable x. I then want to define a function of x through the variable fn.
...
2
votes
1
answer
79
views
Defining multivariable function from previous cell output
In the following, I would like to define a function $h(\theta, \beta, \alpha_1, \alpha_2)$. The function $h$ should be defined by the output of a previous function (which includes the partial ...
1
vote
1
answer
58
views
How to simplify expression depending on former definition?
If
a = x + y
b = x - y
u = a + b
v = a
This gives me for u/v the expression (2 x)/(x + y)...