Group Abstract Group Abstract

Message Boards Message Boards

0
|
5.7K Views
|
9 Replies
|
9 Total Likes
View groups...
Share
Share this post:

Manipulate sliders don't seem to be working?

Posted 3 years ago

I am trying to plot a function that has the form T=f(r,t,s(t)) in the domain (0,0.05). If I input the numerical values of t and s(t), and then plot T as a function of r, Mathematica gives me the graph of T as a function of r.

Plot[T, {r, 0, 0.05}]

But when I try to use the Manipulate function to see how the plot of T as a function of r varies for different numerical values of t and s(t),

Manipulate[Plot[T, {r, 0, R}],
 {{t, 15(*h*)*60*60}, 0, 24(*h*)*60*60},
 {{s, 0.0225}, 0, 0.05}]

I get an output with sliders for t and s(t), but moving the sliders do not change the output. What am I missing here?

Here is the notebook:

POSTED BY: Safi Ahmed
9 Replies
Posted 3 years ago
POSTED BY: Safi Ahmed
Posted 3 years ago
POSTED BY: Safi Ahmed
Posted 3 years ago
POSTED BY: Eric Rimbey
Posted 3 years ago

POSTED BY: Eric Rimbey
Posted 3 years ago
POSTED BY: Eric Rimbey
Posted 3 years ago

In a Manipulate like this,

Manipulate[Plot[T, {r, 0, R}],
 {{t, 15(*h*)*60*60}, 0, 24(*h*)*60*60},
 {{s, 0.0225}, 0, 0.05}]

the s and t variables need to be part of the expression in the body of the Manipulate. What you have in the body, Plot[T, {r, 0, R}], is an expression, it's not a predefined procedure that Mathematica will reference. Mathematica needs to "remember" that expression so that it can recalculate it when s or t change, so it can't just automatically compute it (which, if it did, would presumably expose the s and t as you seem to expect). So, you change s and Mathematica looks at Plot[T, {r, 0, R}] and says, "nothing to do here", because it doesn't see any s in that expression.

On a quick scan, I didn't even see where T was defined, but whatever the expression is that uses s and t, that's the expression you want to plot.

Also, you mention that T depends on t and s(t), but you set up the Manipulate with s and t as independent variables. I'm not sure what you expect to happen here. It seems to me that you should only need t. Whatever the function s is can be used in your definition of T by just applying it to t.

POSTED BY: Eric Rimbey
Posted 3 years ago
POSTED BY: Safi Ahmed
Posted 3 years ago

Mathematica needs to "remember" that expression so that it can recalculate it when s or t change, so it can't just automatically compute it [...] So, you change s and Mathematica looks at Plot[T, {r, 0, R}] and says, "nothing to do here", because it doesn't see any s in that expression.

The expression for T is defined few lines above the plot. Even though I have set values for s and t below that line, I understand that Manipulate should still treat T as an expression T=f(r,t,s(t)). And therefore it should change the numerical value of T if I input a different set of t and s(t). So s and t should exist in the body of Manipulate.

POSTED BY: Safi Ahmed
Posted 3 years ago

No, that’s not how it works. Mathematica will fetch the DownValues/OwnValues of T when needed. It won’t speculatively look ahead to see if those DownValues/OwnValues might in turn depend on something before deciding to evaluate T. Also, in the Manipulate expression, s and t are local, so if T was defined outside of the Manipulate, those s and t variables won’t match anyway.

POSTED BY: Eric Rimbey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard