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$
5
  • $\begingroup$ Try replacing v1 in h[t_] with v1[t]. $\endgroup$
    – Karsten7
    Commented Oct 28, 2015 at 4:42
  • $\begingroup$ Sorry - updated $\endgroup$ Commented Oct 28, 2015 at 4:45
  • $\begingroup$ Try h[t_] = Integrate[v1[t], t] instead. $\endgroup$ Commented Oct 28, 2015 at 4:48
  • $\begingroup$ Oh it worked when I use = rather than := why is this? $\endgroup$ Commented Oct 28, 2015 at 4:52
  • $\begingroup$ h[t_] := Evaluate[Integrate[v1[t], t]]. $\endgroup$
    – Karsten7
    Commented Oct 28, 2015 at 4:52

1 Answer 1

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 and acknowledge you have read our privacy policy.

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