Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.7K Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Same output always from different cells?

Posted 4 years ago
Attachments:
POSTED BY: Cormac Burke
4 Replies

My problem is solved. Many thanks to Gianluca, Rohit and Hans for taking the time to dig me out of a hole.

POSTED BY: Cormac Burke
Posted 4 years ago

In your attached notebook the problem is that the symbol fun, that appears in both Manipulates, is global. Each Manipulate assigns a different value to fun. So fun in both Manipulates will always have the same value, according to the last evaluation. Each change of value triggers an update of both Manipulates.

To get around it fun should be localized. Gianluca has shown one way by using DynamicModule. Here is another way:

Before enter image description here

After enter image description here

POSTED BY: Hans Milton
Posted 4 years ago

It often occurs across different open Notebooks, ie evaluating a cell destabilizes the output of another cell in a different Notebook

This happens if the symbols are in the Global context and both notebooks are running against the same kernel. Changing a value in one notebook changes the value in the other notebook.

One way to avoid this is to use notebook specific contexts.

(* Set permanently *)
CurrentValue[$FrontEnd, CellContext] = Notebook

(* Set for current session only *)
CurrentValue[$FrontEndSession, CellContext] = Notebook

When I share notebooks with others I usually include the latter as an Initialization cell so any definitions in the notebook do not pollute the Global context.

POSTED BY: Rohit Namjoshi

Try isolating each Manipulate inside DynamicModule[{fun},] so that there is no interference between the two panels.

POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard