All Questions
589 questions
0
votes
0
answers
43
views
ReplaceAll (/.) not working as expected in Module [closed]
There is a difference between the following two expressions.
Expression 1:
...
2
votes
4
answers
90
views
Saving and recalling information in Manipulate using localized parameters
I want to allow users to enter some parametrized plots, using the variable t. I want the variable t to be localized to a ...
5
votes
2
answers
270
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 ...
0
votes
0
answers
48
views
Unprotect/Clear only within a local context
I'm working on a project, and I want to Unprotect and ClearAll the properties of NonCommutativeMultiply, but only within a local ...
3
votes
0
answers
54
views
Help understanding why Module variables (e.g. esoteric) sometimes persist as scoped (esoteric$) in the name space, and sometimes not
This part will print the change:
nomos = Names["Global`*"];
Print @ Complement[Names["Global`*"],nomos];
And in between you can run one of ...
1
vote
1
answer
107
views
Should large data be localized in DynamicModule, and why does wrapping Module around it cause syntax warnings?
Apologies for the long question. The question is more pedagogical than practical.
I am trying to improve the performance and usability of a simulation and its visualization. The root of the question ...
0
votes
1
answer
77
views
Symbol in Global Context but List in Module and Block? [duplicate]
Can someone explain the principles underlying the following behavior.
I define the list testD, and then use a Do loop to change values in the list (I realize there are smarter ways but they don't fit ...
0
votes
2
answers
100
views
Local functions of global variables in Blocks
I am very confused by the difference in behaviour of the following two functions:
...
2
votes
1
answer
84
views
Evaluate section in a loop
I would like to evaluate a section several times for different values of some variables. I can evaluate it once with a simple command, but not in a loop.
To evaluate it only once, this code works
<...
0
votes
0
answers
39
views
Making use of a threadpool in parallel computations
I have a user-defined function (implemented as a Module) that performs parallel computations with the application of ParallelDo[]. My function is to be minimized with the help of either FindMinimum[] ...
2
votes
1
answer
106
views
Write a Function to Check User Authorization and Proceed or Halt Execution
I tried the following:
...
2
votes
0
answers
62
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
0
answers
56
views
Problem when code is inside module
I have this code:
...
0
votes
0
answers
50
views
Function returning error every other run
Disclaimer: I am new to Mathematica but have some experience with other programming languages.
I have defined the following function (simplified version):
...
1
vote
0
answers
69
views
Problem defining Function inside Module to verify ODE solution [duplicate]
I modified the question. It turns out this problem has nothing to do with using a package. New style or standard style./
Same problem shows in a normal module in notebook.
This is the most bizzar ...
0
votes
0
answers
68
views
Defining a Function that Can Optionally Output an Arbitrary Number of Tables and Graphs
I'm importing some data from a csv file, performing various filtering operations on it, and then constructing graphs. I'm trying to define a function that does it 'all,' that supports the importing, ...
2
votes
2
answers
50
views
How to fix parameter locally for iterating recursion equations
The following is a simplified version of a more detailed problem.
I have two coupled recursion equations of two variables, x and y. One equation also depends on a parameter, c:
...
0
votes
1
answer
49
views
How can I implement dependence between locally defined variables in With? [closed]
I have a procedure that randomly selects a list element and compares the element value to the value of its position. If a condition is met, the element is replaced. The following works
...
-1
votes
2
answers
103
views
How to Block built-in functions conditionally in a single Block statement? [closed]
I have used the following method and it seems to be working. Just posting here since this way seems hacky. So if anyone can point a better way.
...
1
vote
2
answers
99
views
Programmatically establishing controllers for Manipulate inside a module
I am trying to create a module that allows users to cycle lists to look for a pattern and need a way to programmatically establish the number of controllers depending on the number of lists being used....
0
votes
1
answer
62
views
Why do I get a wrong data structure using Module? [closed]
I am using Module and reading rawlen.txt files from nb100, nb200 , ... folders. I have written a piece of program to calculate strain and I expect the results to have the following structure:
{{0.}, {...
5
votes
1
answer
51
views
How does the scoping in Mathematica work using with blocks? [duplicate]
I'm attempting to understand the following scoping issue:
...
0
votes
0
answers
49
views
Substituting solution into an equation in a module
I have this model which gives me list as an output
...
5
votes
3
answers
160
views
Evaluation control of nested With, If and Integrate
Can you explain the behaviour of the following?
The first With outputs unevaluated If.
So in the second ...
0
votes
0
answers
80
views
Red colored font in code
To avoid affecting lamda in other part of my notebook, I have wrapped code with Module. After wrapping, red colored font appeared.Could I know the reason?
...
11
votes
2
answers
517
views
What's the difference between With and ReplaceAll?
A wolfram Tutorial mentions that ReplaceAll and With are similar:
The way ...
3
votes
0
answers
68
views
Writing 'yield' style generator function
Just out of personal curiosity because I can't think of any solution. Probably, it's not possible, but I want a decisive answer. Is there some clever way of implementing the following function?
...
1
vote
1
answer
85
views
Define list of local variables to be parsed to Module
I have a Module which has $n$ local variables, say $a_i$. Now I want to write my Module in such a way that I do not need to change the code for varying $n$.
My approach is
...
1
vote
2
answers
83
views
SortBy does not work correctly when nest in Evaluate in With in Block
I have got some formula in Mathematica, then I want to pass value to verify them.
full code
...
4
votes
3
answers
157
views
With function replace rule does not work in
If I define an expression , and evaluate it in With function, replace rule does not work.
sumT = TA + TE;
With[
{TA = 0.1, TE = 0.2},
{TA + TE, sumT}
]
output
<...
0
votes
0
answers
63
views
Using a module that turns the output of Findroot into a function of a variable
I am trying to create a module that finds the root b* of some equation with two variables b and ...
0
votes
2
answers
112
views
Using Dynamic string output inside Block
Inside a Block, I have (among other things) a string output that is updated during an internal for loop in the following (schematic) way:
...
0
votes
1
answer
139
views
Using Manipulate for initial guess to nonlinear fitt, feed the result back to Manipulate (and repeat) for a general model with indexed parameters
I have been trying to put toghether a visual method to help fit experimental data with peaks. I have stumbled upon this answer which is very similar to where I got. But it is not sufficiently general ...
1
vote
2
answers
72
views
How to extract manipulated indexed variables from Manipulate
I am struggling with getting values of variables that are manipulated with Manipulate:
The code:
...
0
votes
0
answers
42
views
Manipulate with With and without - scope of variables
I am struggling with some basic concepts:
Why this works:
...
4
votes
0
answers
82
views
Temporary symbol leaks into public context?
This phenomenon has confused me a long time. Consider the following package example,
...
0
votes
0
answers
62
views
how to use subscripted variable such as a_i as the control of Manipulate?
I'd like to define a series of variables called $l_1$,$l_2$, etc., in Mathematica, using the "ctrl+_" shortcut. Moreover, I want to use these variables as the controls of a Manipulate[] ...
0
votes
0
answers
104
views
Interactive control panel using dynamic is surprisingly slow
I am hoping to create a user interface for performing gaussian fits on two dimensional data. I made a basic grid of various controls and labels. The tool works, but it's much slower than I anticipated,...
1
vote
1
answer
84
views
Dynamic text input of equation for graphing
I'd like a simple interface where the user can input (by text) a function $f(x)$, and then the function, its even part, and its odd part are all plotted on the same axes. I'd also like PlotLegend to ...
0
votes
1
answer
52
views
How to make this bisection code work for different equations?
I am very new to Mathematica. I have this code of Bisection Method for finding a root of a polynomial.
...
2
votes
0
answers
97
views
Most efficient way to define several local constants in a function -- Block or nested Withs?
Sorry if this is kind of a noob question but I'm wondering what the best-performing approach is to the following: I'd like to define several local constants in the body of a function, each of which ...
2
votes
0
answers
79
views
With[{a=1},{b=a},b] in 13.2 does evaluate to 1 [duplicate]
This isn't documented, and the front end highlights the second comma and third argument in red, but it's used in DownValues[Once][[3]] and is very convenient. Anyone know more?
1
vote
1
answer
80
views
Function definition inside Module with local symbol
Usually if I want to define a function using an expression I do:
expr=x^2;
f[x_]=expr;
which usually works and give f a defination.
But now if I want to do the ...
4
votes
1
answer
99
views
Passing control values out of nested Manipulates
I am building a "batch photo cropper" UI.
I have a list of images to crop, and I can use Manipulate to make a nice cropping UI for each one:
...
5
votes
1
answer
423
views
Is this buggy behavoir of Module solved? [closed]
I have just found out about this bug of Module, i.e. the creation of "zombie"-variables in some cases (see also this post).
I couldn't find a post saying ...
1
vote
1
answer
93
views
how to achieve “for(int i,i<=3,i++){}” of C++ in Mathematica [closed]
when i use Mathematica to do some small programmings, i always need to pay attention to variables-namings, i just wonder is there a way to achieve “for(int i,i<=3,i++){}” of C++ in Mathematica.
...
1
vote
1
answer
132
views
How to convert a function with named arguments to a pure function?
A function is defined with named arguments. How can this function be converted to a pure function that uses slots (#). As a simple example, how can the following:
<...
0
votes
1
answer
74
views
Problem with functions defined in Module in mathematica package
Might be very naive; I am trying for the first time to develop a Mathematica package as shown below. The intended usage is that the user will load the package, specify the input functions 'Model' and '...
2
votes
1
answer
89
views
Finding the output of the nested CompoundExpression
I am trying to catch the output expression of a nested CompoundExpression like this
...
2
votes
0
answers
153
views
What is the usage of other "*Block" and "With*"? [closed]
There exist some "kernel functions" that are related to the built-in scoping constructs: Assumptions`AssumptionsBlock, ...