Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

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

Search the Archive

Re: Question about Manipulate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg122766] Re: Question about Manipulate
  • From: George Woodrow III <georgevw3 at mac.com>
  • Date: Thu, 10 Nov 2011 06:51:17 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201111091124.GAA11113@smc.vnet.net>

You need to learn *some* Mathematica Syntax

Define your function with a parameter list, and delayed execution. In your case, f has 3 variables, and should be defined as

f[x_, a_, b_] := Sin[a x + b]

The way you have write it, f is defined as the (constant) expression that takes whatever values of x, a, and b are defined at the moment f was created. Since these are undefined, f would always return the same expression, which never takes on a numerical value.

When you place the expression Sin[a x + b] inside the Plot function, you specify the (local) variables x, a, b as part of the plot and Manipulate functions.

geo3rge


On Nov 9, 2011, at 6:24 AM, mailcwc at gmail.com wrote:

> I tried the following code in Mathematica 8.0
> 
> Clear["Global`*"]
> f = Sin[a x + b]
> Manipulate[Plot[f, {x, 0, 4 \[Pi]}], {a, 0.5, 2}, {b, 0, 2 \[Pi]}]
> 
> The Manipulate block is showed, but the Sin function is not plotted.
> 
> When I replace f in the third line with its definition,
> 
> Clear["Global`*"]
> Manipulate[ Plot[Sin[a x + b], {x, 0, 4 \[Pi]}], {a, 0.5, 2}, {b, 0, 2
> \[Pi]}]
> 
> The Sin function is plotted.
> 
> Is this a bug or a limitation in Mathematica?
> 




  • Prev by Date: Re: Import files on accessible URL and save in
  • Next by Date: Re: Plotting discontinuities using Exclusions
  • Previous by thread: Re: Question about Manipulate
  • Next by thread: Re: Question about Manipulate