1

Consider the following piece of code

dbh_m := 100*dbh 
Manipulate[
 Graphics3D[{Sphere[{0.5, 0.5, 0.5}, Sin[dbh]]},
  PlotRange -> {{0, 1}, {0, 1}, {0, 1}}], {dbh, 0, 1}
 ]

What it does is to plot a 3D sphere of variable radius. If now I modify it like this

dbh_m := 100*dbh 
Manipulate[
 Graphics3D[{Sphere[{0.5, 0.5, 0.5}, Sin[dbh_m]]},
  PlotRange -> {{0, 1}, {0, 1}, {0, 1}}], {dbh, 0, 1}
 ]

It stops working. So my question is, is there a way to let Manipulate know of the "outer context". Or in other terms can I make manipulate interpret the variables?

Manfredo
  • 189
  • 9
  • 1
    The dbh inside the manipulate is actually a local symbol, so dbhM(you really should avoid underscores in variable names!) doesn't 'see' manipulate's dbh (which actually becomes dbh$123213 or something locally). What you should do is define dbhM[dbh_]:=100*dbh and then plot ...Sin[dbhM[dbh]]... inside the manipulate. You might be interested in this post about scoping constructs – N.J.Evans Oct 18 '17 at 12:33
  • Your doubts are addressed in linked topic. Except the problem with dbh_m name which is a beginner mistake. Let me know if you disagree with closing. – Kuba Oct 18 '17 at 12:47
  • I'm ok with closing it. I think having a kind of alias would be more neat than using a function. But I understand the scoping issue... – Manfredo Oct 18 '17 at 12:59

0 Answers0