Given a piecewise function of v[t]
, how to plot its displacement x[t]
?
ClearAll[v, x];
v[t_] := 2 t /; t < 10;
v[t_] := 20 /; 10 <= t < 25;
v[t_] := t - 5 /; 25 <= t < 35;
v[t_] := 30 /; 35 <= t < 50;
v[t_] := -7 t + 380 /; 50 <= t < 55;
v[t_] := -5 /; 55 <= t < 65;
x[t_] := Integrate[v[t], {t, 0, 10}] /; t <= 10;
x[t_] := Integrate[v[t], {t, 10, 25}] + x[10] /; 10 < t <= 25;
x[t_] := Integrate[v[t], {t, 25, 35}] + x[25] /; 25 < t <= 35;
x[t_] := Integrate[v[t], {t, 35, 50}] + x[35] /; 35 < t <= 50;
x[t_] := Integrate[v[t], {t, 50, 55}] + x[50] /; 50 < t <= 55;
x[t_] := Integrate[v[t], {t, 55, 65}] + x[55] /; 55 < t <= 65;
Plot[{v[t], x[t]}, {t, 0, 65}]
The above code produces a lot of errors:
Integrate::ilim: Invalid integration variable or limit(s) in {0.00132786,0,10}.
NIntegrate::itraw: Raw object 0.0013278571428571428` cannot be used as an iterator.
etc...
x[10]
for example, then what do you expected the call tox[t_]
to be?t
will be a number, and then you are doing integrate with respect to thist
which is a number. $\endgroup$