Message Boards Message Boards

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

Same output always from different cells?

Posted 2 years ago

Evaluate the upper cell and BOTH cells show output with 60deg triangles.
Evaluate the lower cell and BOTH cells show output like a patchwork quilt.
The upper cell should show 60deg triangles;
The lower cell should show a patchwork quilt.
How do I correct this intolerable situation?
I get this type of instability often when using Manipulate and Dynamic Updating. It often occurs across different open Notebooks, ie evaluating a cell destabilizes the output of another cell in a different Notebook. Yet I have not seen any reference to this problem in Mma textbooks or online. I hope someone can help me avoid this crippling problem.

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 2 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 2 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

Group Abstract Group Abstract