Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #6296 > unrolled thread
| Started by | "mailcwc@gmail.com" <mailcwc@gmail.com> |
|---|---|
| First post | 2011-11-09 11:37 +0000 |
| Last post | 2011-11-10 12:03 +0000 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Question about Manipulate "mailcwc@gmail.com" <mailcwc@gmail.com> - 2011-11-09 11:37 +0000
Re: Question about Manipulate JasonE <ebaughjason@gmail.com> - 2011-11-10 12:02 +0000
Re: Question about Manipulate Armand Tamzarian <mike.honeychurch@gmail.com> - 2011-11-10 12:03 +0000
| From | "mailcwc@gmail.com" <mailcwc@gmail.com> |
|---|---|
| Date | 2011-11-09 11:37 +0000 |
| Subject | Question about Manipulate |
| Message-ID | <j9domc$b5c$1@smc.vnet.net> |
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?
[toc] | [next] | [standalone]
| From | JasonE <ebaughjason@gmail.com> |
|---|---|
| Date | 2011-11-10 12:02 +0000 |
| Message-ID | <j9gegb$our$1@smc.vnet.net> |
| In reply to | #6296 |
You did not define the function properly.
Try this:
f[a_, x_, b_] := Sin[a x + b]
You will also need to format Manipulate differently:
Manipulate[Plot[f[a, x, b], {x, 0, 6}], {a, 1, 4}, {b, 0, 10}]
Jason Ebaugh
ebaughjason@gmail.com
www.linkedin.com/in/jasonebaugh
On Nov 9, 5:37 am, "mail...@gmail.com" <mail...@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?
[toc] | [prev] | [next] | [standalone]
| From | Armand Tamzarian <mike.honeychurch@gmail.com> |
|---|---|
| Date | 2011-11-10 12:03 +0000 |
| Message-ID | <j9gej6$p08$1@smc.vnet.net> |
| In reply to | #6296 |
On Nov 9, 10:37 pm, "mail...@gmail.com" <mail...@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?
your a and b within the Manipulate are not the global a and b you have
used outside of the manipulate in your definition of f. That is why it
is failing. In this particular case the syntax styling gives a heads
up that they are different beasts.
Mike
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web