5
$\begingroup$

I have simple Manipulation expression, but continuously getting error

Coordinate {x[0.], y[0.]} should be a pair of numbers, or a Scaled or Offset form.

I assume that something is wrong with Graphics, but don't know why Evaluate doesn't give numerical values.

The expression is:

Manipulate [{
     sx = NDSolve[{x''[t] + (2 k1)/m  (x[t] - a) == 0, x[0] == x0, x'[0] == vx0}, x[t], {t, 0, 10}];
     sy = NDSolve[{y''[t] + (2 k2)/m  (y[t] - a) == 0, y[0] == y0, y'[0] == vy0}, y[t], {t, 0, 10}];
     Graphics[{Disk[{Evaluate[x[tl] /. sx][[1]], Evaluate[y[tl] /. sy][[1]]}, 0.1]}, {PlotRange -> 6}]
     }[[1]], 
    {a, 1, 10}, {m, 1, 10}, {k1, 1, 100}, {k2, 1, 100}, {x0, 0, 10}, {y0, 0, 10}, {vx0, 2, 10}, {vy0, 2, 10}, {tl, 0, 10}
]
$\endgroup$
0

1 Answer 1

5
$\begingroup$
Manipulate[{sx = NDSolve[{x''[t] + (2 k1)/m (x[t] - a) == 0, x[0] == x0, x'[0] == vx0},
                 x[t], {t, 0, 10}];
   sy = NDSolve[{y''[t] + (2 k2)/m (y[t] - a) == 0, y[0] == y0, y'[0] == vy0}, 
                y[t], {t, 0, 10}]; 
   Graphics[{Disk[{Evaluate[x[t] /. sx][[1]],  Evaluate[y[t] /. sy][[1]]}, 0.4]},
            PlotRange -> 6] /. t -> tl}[[1]],
 {a, 1, 10}, {m, 1, 10}, {k1, 1, 100}, {k2, 1, 100}, {x0, 0, 10},
 {y0, 0, 10}, {vx0, 2, 10}, {vy0, 2, 10}, {tl, 0, 10}]

enter image description here

To get a hint as to why the original code does not work, try

Evaluate[y[t] /. sy]
(* {InterpolatingFunction[{{0.`,10.`}},"<>"][t]} *)

and

Evaluate[y[tl] /. sy]
(* {y[tl]} *)

Similarly, for x[t].

$\endgroup$
1
  • $\begingroup$ Simple. Thanks. $\endgroup$
    – tobix10
    Commented Oct 10, 2014 at 16:31

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.