- 1,028
- 763
- TL;DR Summary
- Having trouble running Wolfram's NDSolve with physical quantities.
Code:
v0 = Quantity[0.00001, "meters/second"]
x0 = Quantity[1.0001, "meters"]
K = Quantity[1.01, "Newtons/meter"]
M = Quantity[1.001, "kilograms"]
s = NDSolve[{x''[t] == - K * x[t]/M , x[0] == x0, x'[0] == v0}, x, {t, 0, 10}]
... gives this error:
Code:
NDSolve::ndinnt: Initial condition 1.0001m is not a number or a rectangular array of numbers.
What is going wrong here?
====
Edit: Tried adding units to the start and stop time as well...
Code:
v0 = Quantity[0.00001, "meters/second"]
x0 = Quantity[1.0001, "meters"]
K = Quantity[1.01, "Newtons/meter"]
M = Quantity[1.001, "kilograms"]
t1 = Quantity[0.0, "seconds"]
t2 = Quantity[5.0, "seconds"]
s = NDSolve[{x''[t] == - K * x[t]/M , x[0] == x0, x'[0] == v0},
x, {t, t1, t2}]
And now it's saying...
Code:
NDSolve::ndnl: Endpoint 0.s in {t,0.s,5.s} is not a real number.
Attachments
Last edited: