0
$\begingroup$

Good day! I want that with the following code it is possible to enter the minimum and maximum range of the variables x and y, but when running it the following error appears:

Limiting value uMin in {x,uMin,uMax} is not a machine-sized real \ number.

Panel[Manipulate[tick; Dynamic[b = 8]; Dynamic[c = 4]; 
Dynamic[uMin = -5]; Dynamic[uMax = 5]; 
KFigE = Dynamic[
Plot3D[dydx /. {B -> b, C -> c}, {x, uMin, uMax}, {y, uMin, 
  uMax}]],
Grid[{
{Style["PLOT", "Title"], SpanFromLeft, SpanFromLeft},
{Style["Start:", Blue, Bold, 15]},
{Style["Initial Conditions", Blue, Bold, 15]},
{Style["b", Bold, 12], 
 InputField[Dynamic[b], Number, Background -> Lighter[Gray, 0.7], 
  ImageSize -> 80],
 Style["uMin", Bold, 12], 
 InputField[Dynamic[uMin], Number, 
  Background -> Lighter[Gray, 0.7], ImageSize -> 80]},
{Style["c", Bold, 12], 
 InputField[Dynamic[c], Number, Background -> Lighter[Gray, 0.7], 
  ImageSize -> 80],
 Style["uMax", Bold, 12], 
 InputField[Dynamic[uMax], Number, 
  Background -> Lighter[Gray, 0.7], ImageSize -> 80]},
{Button["Do it", tick = Not[tick], 
  Background -> Lighter[Green, 0.5], ImageSize -> {80, 40}],
 Button["Clear", {dydx = Null, b = Null, c = Null}, 
  Background -> LightRed, ImageSize -> {80, 40}],
 Button["Export", 
  Export[SystemDialogInput["FileSave", "untitled"], KFigE], 
  Background -> LightBlue, ImageSize -> {80, 40}, 
  Method -> "Queued"]}}, Spacings -> {2, 1}],
  {{dydx, 3*(B*x + C*y), "Equation", None}, 
  Background -> Lighter[Gray, 0.7], ImageSize -> 200},
  {{tick, False}, None}, TrackedSymbols :> {tick}, 
  ControlPlacement -> Left]]

It only works when the values of uMin and uMax have been previously loaded.

$\endgroup$

1 Answer 1

1
$\begingroup$

Your Manipulate seems very complicated, with unnecessary Dynamic wrappers all over the place. Here's a stripped down version that replicates your issue:

Manipulate[
    Plot3D[dydx /. {B->b,C->c},{x,uMin,uMax},{y,uMin,uMax}],
    Grid[{
        {Control@{{b,Null},InputField[#, Number]&},Control@{{uMin,Null},InputField[#,Number]&}},
        {Control@{{c,Null},InputField[#,Number]&},Control@{{uMax,Null},InputField[#,Number]&}}
    }],
    {{dydx,3 (B x + C y), "Equation", None}},
    ControlPlacement -> Left
]

Since the Plot3D is complaining about uMin and uMax not being numeric, you can wrap the plot in an If statement. The following works fine:

Manipulate[
    If[AllTrue[{uMin, uMax}, NumericQ],
        Plot3D[dydx /. {B->b,C->c},{x,uMin,uMax},{y,uMin,uMax}],
        Graphics[{}]
    ],
    Grid[{
        {Control@{{b,Null},InputField[#, Number]&},Control@{{uMin,Null},InputField[#,Number]&}},
        {Control@{{c,Null},InputField[#,Number]&},Control@{{uMax,Null},InputField[#,Number]&}}
    }],
    {{dydx,3 (B x + C y), "Equation", None}},
    ControlPlacement -> Left
]
$\endgroup$
1
  • $\begingroup$ Works correctly! The best ideas are the simplest. $\endgroup$ Commented May 23, 2019 at 6:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.