       design question, how to have a set of manipulate controls, but have separate expression associated with each control?

• To: mathgroup at smc.vnet.net
• Subject: [mg81087] design question, how to have a set of manipulate controls, but have separate expression associated with each control?
• From: "Nasser Abbasi" <nma at 12000.org>
• Date: Tue, 11 Sep 2007 05:24:55 -0400 (EDT)
• Organization: Cox

```hi;

There is a design problem I am trying to solve. Currently with Manipulate, I
use the following pattern:

process[p1_,p2_,......]:=Module[{},...Plot[],...Plot[],....]
Manipulate[process[p1,p2,....],  {p1,0,1},{p2,0,1},.....]

So that when I update p1 or p2 or p3,.... then process[] is called with
updated p's and it does its work, and makes plots, and life is good.

The problem with this approach, is that now process[], everytime it is
called, will go through all the processing again, and makes all the plots
again with the new set of p's it is called with, even though may be only ONE
of those p's has changed, and this change may be only will affect one plot
inside it, or more generally will affect only part of over all computation,
and there would have been no need to repeat everything all over again, and
update all the plots again. But poor process[] does not know this when it is
called ofcourse.

So how to solve this? What would be really nice is the following:

If I can figure how to make each control have associated with it its own
method (but still have all the controls inside one manipulate so that they
are grouped together.) If this is possible, then when only one control
changes, then this specific control method will run, and it will update the
specific plot, or plots, it only cares about.

This will require that each control method will have access to all the
'other' input control variables as well.

So, I am thinking of this set up:

p1Method[p1_,p2_,......]:=Module[{}, Plot[]]
p2Method[p1_,p2_,......]:=Module[{},......Plot[],....]
p3Method[p1_,p2_,......]:=Module[{},..Plot[]....]
...

Manipulate[Null,
{{p1,0,1},  p1Method[p1,p2,....]},
{{p2,0,1},  p2Method[p1,p2,....]},
{{p3,0,1},  p3Method[p1,p2,....]},
....

Ofcourse, I can already solve this problem, by using a separate manipulate
for separate control like this:

Manipulate[p1Method[p1]}, {p1,0,1}]
Manipulate[p2Method[p2]}, {p2,0,1}]
Manipulate[p3Method[p3]}, {p3,0,1}]
....
and somehow have each other be able to access the other parameters, my be
make them global or something (not good solution)

so you might ask, what is the problem then?

Well, I wanted to have one common display area where all method do the
display into. If I use separate manipulate for separate control, then each
display will go into its own area, and I will also not have the controls
themselves in one area.

For example, I can use Grid, and use Manipulate inside each grid, like this:

foo[n_] := Plot[Sin[n*x], {x, -Pi, Pi}]
foo2[n_] := Plot[Cos[n*x], {x, -Pi, Pi}]
Grid[{{Manipulate[foo[n], {n, 1, 10}], Manipulate[foo2[n], {n, 1, 10}]}}]

But you see now the controls are not close to each others, and the display
area is not 'common'.

I want to have one display area, controls in one place, but separate method
for each control, and shared parameters.

I am sure there is a way to do, I hope so.

I hope I explained this problem.

thanks,
Nasser

```

• Prev by Date: Re: TraditionalForm ordering
• Next by Date: Anomolous behaviour of Penrose Triangle Demonstration