[Date Index]
[Thread Index]
[Author Index]
Re: Manipulating list of functions
*To*: mathgroup at smc.vnet.net
*Subject*: [mg96309] Re: Manipulating list of functions
*From*: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
*Date*: Wed, 11 Feb 2009 05:21:29 -0500 (EST)
*References*: <gmrmek$9vj$1@smc.vnet.net>
Hi Istvan,
You have almost answered your question in your last sencence. Indeed,
why didn't you just move these definition to outside the Manipulate?
They don't belong inside. You may consider Manipulate as an infinite
looping construct, so your code is redefining the same functions over
and over again.
And, since one of the definitions visually depends on the other,
Manipulate thinks it might have changed during one iteration and
therefore a new iteration is necessary to reflect the changes (ad
infinitum).
Just moving the definitions outside Manipulate won't work, though,
because they are the only places with explicit references to the
Manipulate variables a and b. Manipulate needs to see these, otherwise
it won't do anything. The following will work:
DynamicModule[{funcB, funcC, funcList, funcA},
funcA[z_, a_] := Sin[z + a];
funcB[z_, b_] := Cos[z + b];
funcC[z_] := 0;
funcList[z_, a_, b_] := {funcA[z, a], funcB[z, b], funcC[z]};
Manipulate[
Plot[funcList[x, a, b], {x, 1, 10}, Axes -> False,
Frame -> True], {a, 0, 1}, {b, 0, 1}]
]
or
DynamicModule[{funcB, funcC, funcList, funcA},
funcA[z_, a_] := Sin[z + a];
funcB[z_, b_] := Cos[z + b];
funcC[z_] := 0;
Manipulate[
Plot[{funcA[x, a], funcB[x, b], funcC[x]}, {x, 1, 10},
Axes -> False, Frame -> True], {a, 0, 1}, {b, 0, 1}]
]
Cheers -- Sjoerd
On Feb 10, 12:55 pm, replicator... at gmail.com wrote:
> Dear Group,
>
> I have the following code:
>
> Manipulate[
> funcA[z_] := Sin[z + a];
> funcB[z_] := Cos[z + b];
> funcC[z_] := 0;
> funcList = #[x] & /@ {funcA, funcB, funcC};
> Plot[funcList, {x, 1, 10}, Axes -> False, Frame -> True],
> {a, 0, 1},
> {b, 0, 1}
> ]
>
> It returns the Manipulate panel correctly. What annoys me is the cell
> bracket of it that is constantly highlighted, probably because there
> is some calculation going on even when I do not move any of the
> sliders, due to some function-definitions. I'm afraid I do not fully
> understand the cause of it. Nor do I know how to overcome it. Also
> what should I do, if I want to move the funcA, funcB, funcC
> definitions outside of Manipulate?
>
> Thank you in advance
> Istvan
Prev by Date:
**Re: LabeledListPlot**
Next by Date:
**Re: Problem importing HTML with Mathematica**
Previous by thread:
**Re: Manipulating list of functions**
Next by thread:
**Re: Manipulating list of functions**
| |