Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #5173

Re: difference between two commands

From Heike Gramberg <heike.gramberg@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: difference between two commands
Date 2011-09-25 02:33 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <j5m3t7$pgs$1@smc.vnet.net> (permalink)
References <201109230742.DAA07668@smc.vnet.net>

Show all headers | View raw


By default, the variables appearing in a Manipulate are localized. This 
means that for each variable in Manipulate a unique symbol
is created to represent this symbol (similar to for example Module). In 
this case, the c in Manipulate will internally be represented
by something like FE`c$$512. Try for example

Manipulate[HoldForm[c], {c, 0, 1}]

to see what the internal name of the variable c is. The c appearing in 
the definition of p is a global variable and is different to the c
appearing in the Manipulate so it won't get replaced by the value of the 
local c when you're trying to plot p inside the Manipulate.

To get the right behaviour you could do something like

Clear[p];
p[c_, x_] := Sin[c x]
Manipulate[Plot[p[c, x], {x, 0, 10}], {c, 1, 2}]

Alternatively you could set LocalizeVariables->False, but this might 
cause all sorts of undesired side effects so you should be careful
with that.

Heike.

On 23 Sep 2011, at 09:42, Luiz M. Carvalho wrote:

> Hi,
>
> Let
> p := Sin[c x]
> Please, could someone explain to me the difference between those two
> commands
>
> Manipulate[Plot[p, {x, 0, 10}], {c, 1, 2}] and  Manipulate[ Plot[Sin[c
> x], {x, 0, 10}], {c, 1, 2}]
>
> Thanks
> Luiz
>

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: difference between two commands Heike Gramberg <heike.gramberg@gmail.com> - 2011-09-25 02:33 +0000

csiph-web