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.

learn more… | top users | synonyms

2
votes
1answer
66 views

Equivalent command to the Maple indets command

This carries on the discussion here and here. I had mistaken Variable[] to give you ALL variables in an expression, but apparently, it is not meant for that. ...
2
votes
2answers
128 views

Using a variable for two different purposes

I want to name a bunch of tables after the OEIS entries which describe them. Is there any way to use these names for both the table name and the link at the same time? The second line uses the ...
2
votes
1answer
103 views

How to define a matrix with all elements 0? [closed]

A matrix can be defined as M = Array[m, {3, 3}] which gives ...
2
votes
1answer
115 views

Reuse local variable in declaration within With [duplicate]

Considering the richness of Mathematica.SE, I am quite surprised I could not find my answer... I am very sorry if it is a duplicate. Consider the following example: ...
1
vote
3answers
642 views

Better solution than returning a list of 3 values?

I have a function (using SetDelayed) that currently returns 3 values in a list. Later on I use the result of this list along with ...
1
vote
2answers
88 views

Using AddTo in a function

I want to create a function that will take a variable $x$ and reassign the value $x+2$ to $x$. So f[x_]:= x += 2 However: ...
1
vote
2answers
154 views

Why does Evaluate[a[[1]]]=0 assign a value to a variable while a[[1]]=0 doesn't?

I'm trying to do a small page counter with Mathematica, for leting me know about my reading progress on some books. I'm stuck on a problem: ...
1
vote
3answers
374 views

Adding subscripts to variables

I know I can define vars = Map[Subscript[x, #1] &, {"tem", "pressure", "hum", "lat", "alt", "space", "corner"}] and ...
1
vote
1answer
803 views

How to linearize an expression automatically?

I would like to automatically linearize some long equations in the scope of variational calculus. Here follows an example of what I need to do : Given two variables $a_1 = q_1 + \delta q_1$ and $a_2 ...
1
vote
2answers
128 views

Define the square of a function [closed]

Is there any good way to define the square of a function in M9? Usually one can write e.g. f[z_] = 3*Sin[z] etc etc. But is it possible to define ...
1
vote
3answers
118 views

Declare local variable when defining a function to mimic Table[]

The problem: I want to define a function tab to replace the long line Table[f[i,j,k,l],{i,3},{j,3},{k,3},{l,3}] by a shorter ...
1
vote
3answers
1k views

How to create functions of arbitrary number of variables? [duplicate]

In the following code what would be the simplest way to generalize it to say some $N_f$ number of $z$ instead of just $z_1$ and $z_2$? ...
1
vote
2answers
130 views

Add a letter to a variable name from a list

Basically I am searching for a way to add the letter u to an existing list of variables {a,b,c,d} to obtain the variable list ...
1
vote
2answers
216 views

TabView: Reset some dynamic variable on tab selection

Given a TabView panel like this one TabView[{ DynamicModule[{x = False}, {Checkbox[Dynamic[x]], Dynamic[x]}], "foo"}] I ...
1
vote
3answers
74 views

Store matched variables

Edit: I am matching and replacing a particular expression. At the same time... I want to store matched variables for later use. I got it to work with messed up code involving ...
1
vote
1answer
95 views

Solving equations with QuantityVariable

I'm trying to understand how to easily solve equations that use QuantityVariable. Why does this fail? ...
1
vote
1answer
86 views

Plotting with multiple variables [closed]

What is the simplest way of plotting across multiple variables? eg: I would like to plot something like this: Plot[{x^0,x^1,x^2,x^3,x^4,x^5,x^6}, {x, 0, 10}] ...
1
vote
1answer
246 views

Generating a list of symbolic coefficients [duplicate]

I am trying to do something which I assume should be very simple: I want to generate a list with symbolic coefficients that looks like this: ...
1
vote
1answer
196 views

Print indexed (by subscript) variable name systematically

I have some variables : Subscript[S, 1], Subscript[S, 2]...etc. But they are defined in a for loop like For[g = 1, g < 4, g++, Subscript[S, g] = g]; Later, I ...
1
vote
1answer
407 views

How do I use a matrix that has a variable?

I seem to be getting an error whenever I try running this piece of code. Matrix12[n_] := {{1, 0}, {0, {\[Kappa]1[n]}/{\[Kappa]2[n]}}} I've already defined the ...
1
vote
1answer
316 views

How to substitute variables in interpolated function?

I'm looking for the way to substitute variables in interpolated function again to original one. (I want to know how to get P(r, theta) from Psol(v, w).) The original variables : ...
1
vote
2answers
139 views

How to tell Mathematica that certain variables are real/imaginary, integer-valued, etc

I'm trying to expedite some quantum mechanical calculations by running them through Mathematica. Expectation values and stuff like that. When I say, for example, ...
1
vote
1answer
76 views

How to form a variable from matrix elements

I have matrix with n rows and 2 columns, say m = {{x11, y12}, {x21, y22}, ..., {xn1, yn2}. Now, I want to form three new variables for example: ...
1
vote
2answers
72 views

Calling variables with use of numbers in their names

I have got few huge matrices named by ascending numbers, e.g. x1, x2, x3,... and I need to do the same operation with all of them - to multiply their components, ...
1
vote
1answer
41 views

How to set the values into some variables from different lists [closed]

I have a list of Values and a list of variables. I want to set the Values into Variables. Assume the following code: ...
1
vote
1answer
157 views

Is linear interpolation applicable here

From my understanding about Linear Interpolation especially of that of Newton's Divided Difference Polynomial, we could get the value of F(x) from the given set of ...
1
vote
1answer
176 views
1
vote
0answers
97 views

How to create a complex variable from dated list values

Can anyone help me to construct a variable "PI" from values of variable x. Variable x represents a group of two time series rj and ri on equal dates(joined two dated lists with states).Variable x have ...
1
vote
0answers
71 views

specifying a list (vector) of arbitrary length

When trying to do symbolic calculations in mathematica involving a space of dimension n, which is arbitrary but fixed, I'd often like to work with vectors that have ...
1
vote
0answers
58 views

Telling mathematica that something is an integer [duplicate]

Is it possible for me to tell mathematica something is an integer? like if I typed Sin[n Pi]+Cos[n Pi] it would tell me it equals 1 for even n and -1 for odd n? ...
1
vote
0answers
65 views

Why the variable cannot use subscript? [duplicate]

Today,I use the Lagarange method to deduce the robot 's dynamic equation .I use the mma to help me calculate. I want to use $$x_B,y_B, v_{Bx}, v_{By}, v_B ^2$$ to represent the point B 's ...
1
vote
0answers
1k views

How to assign (and retrieve) variables with subscripts? [duplicate]

I like to give subscripts to my variable names when the variables are related. I.e., Subscript[r, i] = 3 3 A problem arises when I later assign ...
1
vote
0answers
134 views

Variable scope in nested NMaximize, NMaxValue

I'm trying to use NMaxValue inside other statements (FindRoot and NMinimize). Those statements should bind variable names, but I'm getting weird warnings which seem to indicate that the variables ...
0
votes
4answers
788 views

Specify a variable as an integer

I have a formula that always evaluates to a certain number for any variable X under one condition that X is an integer and ...
0
votes
2answers
112 views

Variable Value as Range

Thank you for the help so far! I would like to assign +/i signs for the function and solution such as (+)(+)(-) and therefore (-). It is working for the first evaluation, λlower, but not for the ...
0
votes
3answers
146 views

Clean-up Code / Reduce variables

I'm writing a playing card simulator of sorts, and everything works fine, but some Modules use a disgusting amount of variables. For Example: ...
0
votes
2answers
139 views

How can I assign some part of data from one list to another list?

I don't know this is correct question or not,but I have a doubt. I have two Lists names are list1 and ...
0
votes
1answer
63 views

How I can define a new function as a function argument?

I need to pass a function with t as independent variable as a function parameter and want to create a new function of the same through this provided the argument of another function. Here is my code. ...
0
votes
2answers
47 views

how to define roots of an equation as a function? [closed]

I need to solve an equation depending on 3variables in only one variables and define the roots as a function of the remaining variables? I used some thing like that: ...
0
votes
1answer
57 views

Is there a command returning information about a particular object? [closed]

Suppose I have a variable var1, a function MyFunction, and a graphic SomePlot. I remember ...
0
votes
1answer
31 views

Indexed variable with alternatives

I have a["tree"] := "oak" a["flower"] := "rose" a["dog" | "cat"] := "animals" I want that the last definition of a behaves ...
0
votes
2answers
124 views

Define a function on a parameter argument set to zero

Say I have an expression (matrix) that depends on several variables. f= {{a, b+c},{2a-b^2,c^5+a b}} I want to define new matrices with the single parameter ...
0
votes
1answer
79 views

Circumventing the default scoping: Assign a variable inside a function [duplicate]

I'm currently trying very hard to assign a variable inside a function. Therefore I'm using a function like this, which should reassign a predefined variable. ...
0
votes
1answer
100 views

Arbitrary number of variables in Module, Block, etc

How do I specify an arbitrary number of variable names and initialize them inside of a Module or Block? For example, I want to do something like: ...
0
votes
1answer
76 views

About Symbolize and Variables

I do believe this sort of similar questions had been asked many times, so I have read a LOT. For example this and this as well as many other related posts. But a glance at what my main question is ...
0
votes
1answer
31 views

Why would this function work only when I make a copy of the variable? [duplicate]

Why would this function work with a copy of the function variable: ...
0
votes
3answers
109 views

Identifying the symbol which has a specific value

I'm writing a program that will solve the value of 1 variable in a 4-variable equality equation, but the variable to be solved will depend on the user's input to the program. This is what I've come ...
0
votes
2answers
152 views

setting real parameters in Hamiltonian matrix

The following Matrix represents my Hamiltonian. m = {{ B/2 - d - j/2 + a, (Sqrt[2]*j)/2, M}, {(Sqrt[2]*j)/2, B/2 + a, 0}, {M, 0, (-3*B)/2 - d + j/2 + a} How can ...
0
votes
2answers
114 views
0
votes
1answer
73 views

Collecting variables from Subscript

I have followings set: t = Transpose[{x[#] & /@ Range[20], RandomInteger[15, 20]}]; Subscript[#[[1]], #[[2]]] & /@ t The code is just to build my set.So ...