MathGroup Archive 2010

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

Search the Archive

Re: Very very basic question about Mathematica expressions


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