Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Very very basic question about Mathematica expressions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg111135] Re: Very very basic question about Mathematica expressions
  • From: dr DanW <dmaxwarren at gmail.com>
  • Date: Wed, 21 Jul 2010 07:14:35 -0400 (EDT)
  • References: <i23k1j$epv$1@smc.vnet.net>

I ran into this problem yesterday.  I don't know exactly why it
happens, I think it has something to do with the way Manipulate
localizes variables.  To solve it, I use a trick I found that lets me
take an expression built up of global symbols and localize the
symbols. Your trivial example:

s = x + h

Make a function out of it.  The Evaluate[] is necessary to evaluate s,
which replaces it with x+h

sfnc = Function[{x, h}, Evaluate[s]]

Now the Manipulate[] works fine

Manipulate[Plot[sfnc[x, h], {x, 0, h}], {h, 0.1, 1}]

I find myself using this trick a lot.

Regards,
Daniel


  • Prev by Date: Re: Very very basic question about Mathematica expressions
  • Next by Date: Re: Help Mathematica simplify this
  • Previous by thread: Re: Very very basic question about Mathematica expressions
  • Next by thread: Re: Very very basic question about Mathematica expressions