Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #6317
| From | George Woodrow III <georgevw3@mac.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Question about Manipulate |
| Date | 2011-11-10 11:55 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j9ge3p$op1$1@smc.vnet.net> (permalink) |
| 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@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 comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: Question about Manipulate George Woodrow III <georgevw3@mac.com> - 2011-11-10 11:55 +0000
csiph-web