2
$\begingroup$

I can't seem to work out why nothing is showing when I try to plot h[t] in the example below:

pL = 1;
fL = 0.1;
eV = 200;
bR = 0.1;
g = 9.81;

m[t_] := pL + (fL - t*bR)
v1[t_] := eV*Log[m[t]/(m[t] - bR*t)] - g*t
h[t_] := Integrate[v1[t], t]
Plot[h[t], {t, 0, 10}]

Am I missing something completely obvious?

$\endgroup$
  • $\begingroup$ Try replacing v1 in h[t_] with v1[t]. $\endgroup$ – Karsten 7. Oct 28 '15 at 4:42
  • $\begingroup$ Sorry - updated $\endgroup$ – Phil O'kelly Oct 28 '15 at 4:45
  • $\begingroup$ Try h[t_] = Integrate[v1[t], t] instead. $\endgroup$ – J. M. will be back soon Oct 28 '15 at 4:48
  • $\begingroup$ Oh it worked when I use = rather than := why is this? $\endgroup$ – Phil O'kelly Oct 28 '15 at 4:52
  • $\begingroup$ h[t_] := Evaluate[Integrate[v1[t], t]]. $\endgroup$ – Karsten 7. Oct 28 '15 at 4:52
2
$\begingroup$

I think this is probably a duplicate but Plot has attributes HoldAll. As @J.M. suggested you could use Set rather than SetDelayed (i.e. = rather than :=) but for some cases that may not be desirable. If you need to use SetDelayed you could do the following as a work around:

Plot[h[t], {t, 0, 10}, Evaluated -> True]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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