Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #6317 > unrolled thread
| Started by | George Woodrow III <georgevw3@mac.com> |
|---|---|
| First post | 2011-11-10 11:55 +0000 |
| Last post | 2011-11-10 11:55 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Question about Manipulate George Woodrow III <georgevw3@mac.com> - 2011-11-10 11:55 +0000
| From | George Woodrow III <georgevw3@mac.com> |
|---|---|
| Date | 2011-11-10 11:55 +0000 |
| Subject | Re: Question about Manipulate |
| Message-ID | <j9ge3p$op1$1@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@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?
>
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web