Skip to main content

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.

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 ...
Māris Ozols's user avatar
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 ...
azerbajdzan's user avatar
  • 24.1k
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 "...
McNess's user avatar
  • 55
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 ...
Me.F's user avatar
  • 11
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 ...
csn899's user avatar
  • 1
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 ...
NemoX's user avatar
  • 31
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 ...
VertexVexed's user avatar
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 ...
MathArt's user avatar
  • 243
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&...
Xorker's user avatar
  • 23
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, ...
Dinos Volanis's user avatar
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. ...
VertexVexed's user avatar
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 ...
sam wolfe's user avatar
  • 4,953
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. ...
Rudyard's user avatar
  • 471
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 ...
John Doe's user avatar
  • 271
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)...
user57467's user avatar
  • 2,788