Questions tagged [assignment]
For questions relating to assignments to symbols, patterns, or expressions.
284
questions
1
vote
0
answers
32
views
Hold around SetDelayed with Graphics [duplicate]
Minimum Working Example
I've defined my own plot function, which does a lot of stuff to the inputs before passing it into the Graphics function. Because of that, I'...
0
votes
0
answers
55
views
Define a function using output of another function [duplicate]
I am away from my computer and therefore unable to experiment, but I am keen to scribble down a few Mathematica operations in note form ready for my return. So, forgive the simplistic question…
Say I ...
1
vote
1
answer
32
views
Using plot on named expression and explicit expression produces different results
There is some strange behaviour in Mathematica which I don't understand. If you call a function like ContourPlot on two identical expressions (one a named expression, and the other the same expression ...
2
votes
1
answer
60
views
How to assign a value for specific Indeterminate expressions?
I wanted to form a list as follows
j=1;
Table[(i-1-j)^k, {i,2j+1}, {k,-j,j}]
However, an error message occurred since the list included none positive powers of ...
0
votes
0
answers
42
views
Strange behavior with setting multiple values simultaneously
I'm having some strange behavior when trying to set multiple variables using {x,y,z} = {1,2,3}.
When I enter "{a,b,c,a',b',c'} = {1,2,3,4,5,6}", it sets a,b,c,a',b',c' to 1,2,3,4,5,6 as ...
0
votes
1
answer
42
views
Error: Invalid integration variable or limit(s) in {-6.28293,0,\[Pi]/2}
When i try to evaulate h at vaule (for example 0), i get a result. When i directly plot the output of h, it also works, but when ...
3
votes
4
answers
404
views
Define a delayed function depending on a global variable as though the variable's contents was pasted
Problem
Say I previously defined a variable (maybe through some extensive calculation)
thing = (a+x)y
Then, I want to use that expression elsewhere. In general, I ...
2
votes
1
answer
133
views
How to assign a value to something inside a module globally? [closed]
Let's say I created a function that calculates something inside a module. How do I assign that result to a global value?
Let's say I have this:
...
1
vote
0
answers
70
views
Why =. is not clearing the value of a variable in this case? [closed]
I am reading "Mathematics and Algorithms" as part of the Wolfram Tutorial series.
In "Values for symbols" section of the "Algebraic Calculations" chapter it is described ...
0
votes
0
answers
30
views
ToExpression in nested Set/SetDelayed
Suppose we have the following definitions.
...
1
vote
1
answer
41
views
Manipulating the list with variables
I am trying to find the maximum element of the list for a given value of variable $c$.
The example of the list is as follows:
...
0
votes
1
answer
56
views
Symbolic re-assignment of products
Suppose I have some symbolic tensors $X,Y$ and I want to assign
X.Y
into something else without specifying what $Y$ is. For example, I may want $Y$ to serve as ...
3
votes
1
answer
77
views
Problem with parametric integral with variable bounds
d[p_, B_] := \!\(
\*SubsuperscriptBox[\(\[Integral]\), \(-B\), \(+B\)]\(Cos[
p\ x] \[DifferentialD]x\)\)
Plot[d[x, 2], {x, -10, 10}, PlotRange -> Full]
I ...
1
vote
0
answers
43
views
The assignment problem in Plot function [closed]
I used Mathematica to plot a system of equations:
Plot[{y = 2 x - 3, y = x/2}, {x, -5, 5}, Axes -> True,
AxesLabel -> {"x", "y"}, PlotLabels -> {"2x-y=3", "...
0
votes
0
answers
29
views
Set keeps RHS unevaluated when RHS is a Module variable [duplicate]
Consider the simple code
...
0
votes
0
answers
54
views
Assign different type of balls into output containers with constraints
The problem is to asssign all differend kind inputs to outputs.
For example colored balls.
On the input we can receive max 5 different type of colored balls any with amount.
The amounts for the inputs ...
1
vote
1
answer
34
views
Delay evaluation of Chop until its argument has no symbols? (== has this behavior, Chop does not)
With Equal (==), if a and b are undefined symbols, a==b does not evaluate. This way we can ...
1
vote
0
answers
58
views
several actions inside If condition [closed]
Trying to write code with If, if it is correct to perform a number of actions.
I am a beginner user in mathematica and not sure the form of writing are correct.
What I'm asking in simple, this is the ...
6
votes
2
answers
92
views
Error message not reproduced at reevaluation, SetDelayed cache?
Mathematica v13.0:
nr:=HoldForm@Evaluate@Function[t,x@t][]
then evaluate
...
3
votes
4
answers
359
views
Defining a function iteratively without Mathematica getting stuck in a recursion loop
I have the following code:
...
1
vote
0
answers
45
views
How can I access to the needed part of this expression? [duplicate]
I have defined a list like this:
F[1][t] = ConstantArray[a1, 10]
Now I want to assign to some of the elements the value 1; I ...
0
votes
1
answer
51
views
Program works, but then fails when I write it inside Module [duplicate]
I'm new to Wolfram Language; I'm trying to get used to it by writing a bunch of code and programs, being one of them the algorithm for the bisection method.
When I write the algorithm outside of a ...
3
votes
2
answers
139
views
How to make c[n_, x_, y_] := ToExpression["p" <> ToString[n]] = {x, y} work?
I am trying to do the following:
c[n_, x_, y_] := ToExpression["p" <> ToString[n]] = {x, y}
That is: Evaluating ...
0
votes
1
answer
76
views
Forcing mathematica not to substitute some terms in an expression
I have an expression c which should be defined before the function and a function f defined as follows:
...
1
vote
0
answers
113
views
Extracting expressions from LHS of an assignment
I need to list all variables in a notebook containing several Set assignments, lhs=rhs, and equations, ...
0
votes
1
answer
80
views
NIntegrate seems to not recognize multiplication of Piecewise function and f[t_]:= function, Why?
Considering inputs:
vti={0, 1.5, 2.4, 5.0675, 7.735, 10};
Vscc=1.5; PSA=0.025; f=0.6; m=10;
I defined a function "pwtemp2", using "FC1" and &...
0
votes
0
answers
91
views
Can't create matrix function of symbolic functions and assign values to elements
So I have a problem regarding the symbolic matrix value assignment.
Say I create a matrix function as:
P[t_]:= {{P1[t]}, {P2[t]}, {P3[t]}};
Then I want to assign ...
0
votes
0
answers
55
views
How to use Mathematica to return value from for-loop [duplicate]
I tried to use Mathematica to implement random generator. The pseudo code I use is as following:
...
0
votes
1
answer
55
views
any way to store the values of the controls of a Manipulate so that one can reuse them in the future excutions
I’m using Manipulate[] to adjust several parameters, which will eventually generate some figures. After I get the desired view, I’d like to store the set of control parameters so that I can reuse them ...
0
votes
0
answers
55
views
Block Behavior, but for Function Assignment instead of Variable Assignment
We can define a function using a variable b that does not appear as an argument, and then using Block, change the output of the ...
2
votes
1
answer
242
views
Cannot assign variable value inside Do Loop
This is more of a conceptual problem.
Suppose I have three lists.
x1 = {1, 2, 9, 10};
x2 = {5, 6, 7};
x3 = {9, 10, 13};
Now, I wish to keep only the first two ...
0
votes
1
answer
66
views
Avoiding For loops to perform an assignment to a variable with indices of user-choice [duplicate]
I am looking for an efficient way to perform the following operation without For loops
...
0
votes
0
answers
41
views
Going between assignment rules and functions
I am trying to develop a model using Mathematica, and continuously run into difficulties going between the outputs of various functions (Solve, Differentiate, etc.) and back to functions (in the ...
4
votes
2
answers
109
views
Assignment with Span to Indexed Variable
If I use span to assign a value to every element in a "column", it miraculously works:
...
2
votes
1
answer
315
views
How can I list the common elements of two lists?
The elements of both lists are given as
A={9,5,9,3}, B={9,9,5,5}
In this case, how can I list the list {9,5,9} of the common elements of the two lists?
(The order does not matter.)
1
vote
1
answer
108
views
pure function assignment
I do not understand this statement from the Introduction to Dynamic tutorial:
...
2
votes
0
answers
58
views
Certain plotting functions are setting variables unwantedly
I came across the following problem. Certain plotting functions set variables to values, which I do not want. For example, if I run SliceVectorPlot3D with an ...
2
votes
1
answer
56
views
How can I transform equation results into an array of values? [closed]
I would like some help. I executed the following code:
Solve[Det[(s IdentityMatrix[2]) - A] == 0]
which yielded the following results at the output:
...
0
votes
0
answers
66
views
Proper way to construct a function that takes too long to plot and integrate
Consider the functions phi[t_] and psi[t_] defined in the code below. These are used as basis functions for interpolation ...
1
vote
0
answers
88
views
Fast definition of sparse tensor
I'm defining a sparse array through
...
0
votes
0
answers
29
views
Extract actual result from equivalence [duplicate]
When I get a result like this {x -> -0.5 - 0.866025 I}, how do extract just the number: -0.5 - 0.866025 I. I can do this with the .rhs() method in Sagemath but I can't find the function in ...
1
vote
1
answer
50
views
Why does the delayed functional assignment evaluate to `5=6`? [closed]
Why is it that
x=5
x=x+1
nicely evaluates to 6, but the following
...
2
votes
0
answers
81
views
Referring to matrices with index [closed]
For exampe I have two matrices, with index 1 and 2
Mat[1] = ConstantArray[0, {2, 2}]
Mat[2] = ConstantArray[0, {2, 2}]
I wanna assign new value with
...
2
votes
2
answers
206
views
How can I get output from Reduce assigned to a variable? [closed]
I use Reduce to solve an 3rd order equation, and the output is given as the OR'd combination the solution variable. Normally, I can do a replacement to assign the value to a variable, but that doesn'...
1
vote
1
answer
58
views
How to list automorphisms on a finite set and analyze them
Let s be a finite set of integer lattice points, for example s = { {0,0} , {0,3} , {1,1} , {0,2} }.
I am trying to do two things:...
0
votes
4
answers
78
views
Only Reals Rules
I have a huge array of rules with many variables, such as
...
1
vote
0
answers
51
views
Errors with assigment and no errors with replacement rule, why? [closed]
So I have an expression, let's call it f11 which is a function of t of this form f11= a1*t^(-4)+ a3*t^(-3)+... and so on up until a finite positive power of t. In ...
0
votes
1
answer
61
views
Using results from Nmaximize in loop
I try to Append the vector S by z+x whereby z and ...
0
votes
3
answers
133
views
Assign value to the symbol returned by function
Ok, so here is example code:
Clear[p, flag, k];
p = 2;
k = 1;
flag = True;
If[flag, p, k] = 0;
p
After that I get the message
...
3
votes
2
answers
230
views
Set value in a list at given position
Consider
r = Array[Total[{##}] &, {3, 3}]
(*{{2, 3, 4}, {3, 4, 5}, {4, 5, 6}}*)
pos = {{1, 1}, {2, 2}};
vals={100,200}
This
...