MathGroup Archive 2007

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

Search the Archive

Re: novice needs help using Manipulate with Plot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg78466] Re: novice needs help using Manipulate with Plot
  • From: dh <dh at metrohm.ch>
  • Date: Mon, 2 Jul 2007 06:55:45 -0400 (EDT)
  • References: <f68458$eoh$1@smc.vnet.net>


Hi,

Manipulate localizes the variable m. It is then different from the 

global variable m. Therefore, if you do not want to define your function 

inside Manipulate, you must replace the variable of your function by the 

variable of Manipulate. This can be done e.g. by a parameter as you 

already found or by a replacement rule:

test:=mm x

Manipulate[Plot[Evaluate[test/.mm->m],{x,0,10}],{{m,1},0,2}]

The Evaluate is there for efficiency.

hope this helps, Daniel



PHILLMAN5 at gmail.com wrote:

> Manipulate seems at first to be very powerful, but I am having trouble

> using it with my own functions.  To vastly simplify my problem say I

> want to plot y = m x, with x going from 0 to 10, with the slider in

> Manipulate controlling m.  I have tried the following:

> 

> test := m x

> Manipulate[Plot[test, {x, 0, 10}], {{m, 1}, 0, 2}]

> 

> test3[x_] := m x;

> Manipulate[Plot[test3[x], {x, 0, 10}], {{m, 1}, 0, 2}]

> 

> don't seem to work.  If you define the function with m as a formal

> parameter, like the following it does.

> 

> test2 = #1 #2 &;

> Manipulate[Plot[test2[m , x], {x, 0, 10}], {{m, 1}, 0, 2}]

> 

> test4[m_, x_] := m x;

> Manipulate[Plot[test4[m, x], {x, 0, 10}], {{m, 1}, 0, 2}]

> 

> Is there anyway to write functions to work with Manipulate without

> have to have all the slider(s) formally written as a parameter to the

> function?

> 

> 




  • Prev by Date: Re: UI Question / Threading
  • Next by Date: Re: Re: [Mathematica 6] Integrate strange result
  • Previous by thread: Re: novice needs help using Manipulate with Plot
  • Next by thread: Re: novice needs help using Manipulate with Plot