Questions tagged [assignment]

For questions relating to assignments to symbols, patterns, or expressions.

Filter by
Sorted by
Tagged with
3 votes
1 answer
43 views

Choosing numbers whose divisors can be partitioned into subsets having the equal sum

How can we find the list of natural numbers between 100 to 10000, whose positive divisors can be partitioned into three subsets such that sum of all the elements in three subsets will be equal?
user avatar
4 votes
1 answer
128 views

Choosing a subset of a set based on the sum of its elements

How can we choose a subset of a set based on the sum of the elements of the subset? For instance, n=6 dn=Divisors[n] sn=DivisorSum[n,#&] Is it possible to ...
user avatar
  • 41
0 votes
0 answers
52 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 ...
user avatar
  • 1
1 vote
0 answers
47 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 ...
user avatar
  • 215
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 ...
user avatar
  • 6,104
0 votes
1 answer
45 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 ...
user avatar
3 votes
2 answers
132 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 ...
user avatar
  • 4,791
0 votes
1 answer
63 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: ...
user avatar
  • 340
1 vote
0 answers
79 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, ...
user avatar
  • 433
0 votes
1 answer
67 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 &...
user avatar
0 votes
0 answers
73 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 ...
user avatar
0 votes
0 answers
53 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: ...
user avatar
  • 47
0 votes
1 answer
48 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 ...
user avatar
  • 675
0 votes
0 answers
53 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 ...
user avatar
2 votes
1 answer
164 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 ...
user avatar
  • 1,018
0 votes
1 answer
62 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 ...
user avatar
0 votes
0 answers
37 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 ...
user avatar
  • 3
4 votes
2 answers
90 views

Assignment with Span to Indexed Variable

If I use span to assign a value to every element in a "column", it miraculously works: ...
user avatar
  • 1,393
2 votes
1 answer
175 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.)
user avatar
  • 1,091
1 vote
1 answer
100 views

pure function assignment

I do not understand this statement from the Introduction to Dynamic tutorial: ...
user avatar
  • 11
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 ...
user avatar
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: ...
user avatar
0 votes
0 answers
61 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 ...
user avatar
  • 745
1 vote
0 answers
80 views

Fast definition of sparse tensor

I'm defining a sparse array through ...
user avatar
  • 459
0 votes
0 answers
26 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 ...
user avatar
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 ...
user avatar
  • 229
2 votes
0 answers
66 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 ...
user avatar
  • 701
2 votes
2 answers
142 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'...
user avatar
  • 187
1 vote
1 answer
49 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:...
user avatar
0 votes
4 answers
68 views

Only Reals Rules

I have a huge array of rules with many variables, such as ...
user avatar
  • 31
1 vote
0 answers
50 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 ...
user avatar
  • 165
0 votes
1 answer
44 views

Using results from Nmaximize in loop

I try to Append the vector S by z+x whereby z and ...
user avatar
  • 313
0 votes
3 answers
82 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 ...
user avatar
3 votes
2 answers
145 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 ...
user avatar
  • 902
0 votes
2 answers
84 views

Using a list as arguments in a function

This might sound a little silly question but I cannot get my code work. Here is the problem: I have quite a few lists of data which are basically beam profiles. I am using ...
user avatar
  • 37
2 votes
1 answer
57 views

Number of values stored in a function

Suppose I run this: f[0] = 1; f[n_] := f[n] = 2 f[n - 1]; f[1000] Now there will be 1001 values stored in f, and ...
user avatar
  • 1,055
1 vote
2 answers
43 views

How can I use Part Assignment to change sublists into other sublists (without changing levels)?

Here's a 5x5 grid. Using predefined starting points, I'd like to change some sublists into something else (e.g., the values for a color, "drawing an opaque box"). ...
user avatar
  • 73
3 votes
3 answers
516 views

Changing value of specific element in an array. (Converting code from MATLAB to Mathematica)

Can we change the value of a specific element of an array in Mathematica? Basically, I have the following given MATLAB script which writes a big 3N-by-3N matrix $h$ by combining two 3-by-3 matrices $...
user avatar
1 vote
1 answer
64 views

Scan and Set over multi-dimensional data

Suppose I have the following: Table[x[i,j] = f[i,j], {i,1,10},{j,1,10}]; I want to set variables x[i,j] to have value ...
user avatar
  • 20.4k
1 vote
1 answer
74 views

Default Options not working in user-defined function for SymbolName

Abstract I have a function objectName[symbol] that returns the SymbolName as both a standalone function or when nested inside ...
user avatar
  • 1,647
1 vote
1 answer
109 views

Setting a function equal to another function then Clearing the latter

I have a loop in which several values of a function are computed, depending on the values for that function that were computed in the previous iteration of the loop. This could be implemented ...
user avatar
  • 1,375
1 vote
1 answer
97 views

Set: in part assignment is not a symbol [closed]

This is probably a basic question but I am new to Mathematica, so please help me out here. I have the following piece of code: ...
user avatar
  • 125
2 votes
2 answers
56 views

Cannot understand meaning of "identical"

This came up in the context of plotting solutions to NDSolve, but I've reduced it to the following issue. This really has me scratching my head. ...
user avatar
4 votes
2 answers
112 views

Using pure functions to assign a value to variable depending on whether it has been defined already

Let's say I want to assign to a variable the value $2020$ if it has not already been defined and do nothing if it has. In short, for a variable $a$, I want to achieve the functionality of ...
user avatar
  • 471
6 votes
4 answers
251 views

Assigning a string to variables names

I have the list n1 = {{REL1, "REL.csv"}, {RAND1, "RAND.csv\"}}. That is {{variable name, string}, {name, string}}. I want ...
user avatar
  • 125
2 votes
1 answer
46 views

Problem with superscript

I would like to know if there is option to make such scrpits like in this picture below. Is option to put letter instead of a *?
user avatar
  • 25
4 votes
1 answer
122 views

Why the difference in performance? Array vs List and `Delete` vs `Nothing`

In a previous question I was warned against the use of Nothing to delete elements from a list, and rather use Delete. Being of ...
user avatar
7 votes
1 answer
109 views

How would you explain Nothing[] weirdness? [duplicate]

I would like to use Nothing[] to make some elements of a list invisible. (The intended use is to remove a few unwanted points from a ...
user avatar
9 votes
1 answer
132 views

Why Optional in Set is not held by the HoldFirst attribute?

When evaluatingf[x_:x0] := x, x0 will be evaluated, regardless of the HoldAll attribute of <...
user avatar
4 votes
2 answers
226 views

Using module to define a function that calls another function: Should i use set-delayed (:=) or set (=)

Suppose that I have a function f[x_,y_,z_]=x*y*z and now suppose I want to consider a specific application where z is a ...
user avatar

1
2 3 4 5 6