# Using parts of piecewise function

I define:

 f[x_] := Piecewise[{{5, 0 <= x < 10}, {g[x], 10 <= x < 15}, {h[x], x > 15}}]


Then I try to solve ODE:

 a = 0.7
NDSolve[{g'[x] == Sin[x] + 2*With[{t = a*x}, Refine[f[t], 0 <= t < 10]], g == 5},
g[x], {x, 10, 14.2857}]


It gives $g[x]$ as InterpolatingFunction.

Then - plot it:

 Plot[f[x], {x, 0, 11}]


But it plots $f[x]$ only in {x, 0, 10}, where the function is defined manually. So, plotting $g[x]$ also doesn't give any result. I tried other definitions of Piecewise function (such as $f$), but it also didn't work. Solving ODE for $f[x]$ (not for $g[x]$) is helpless.

So, my question is: Can I use different undefined parts of Piecewise function for calculations? If not, are there another possibilities to do this in Mathematica maybe?

f[x_] := Piecewise[{{5, 0 <= x < 10}, {g[x], 10 <= x < 15}, {h[x], x > 15}}]

a = 0.7
NDSolve[{g'[x] == Sin[x] + 2*With[{t = a*x}, Refine[f[t], 0 <= t < 10]], g == 5},
g[x], {x, 10, 14.2857}]

g[x_] = g[x] /. % // First

Plot[f[x], {x, 0, 15}] Clear[g];

f[x_] = Piecewise[{{5, 0 <= x < 10}, {g[x], 10 <= x < 15}, {h[x], x > 15}}] a = 0.7;
Clear[g];
g[x_] = g[x] /.
NDSolve[{g'[x] == Sin[x] + 2*With[{t = a*x}, Refine[f[t], 0 <= t < 10]],
g == 5}, g[x], {x, 10, 14.2857}][];

Plot[f[x], {x, 0, 11}, AxesOrigin -> {0, 0}] However, DSolve can be used rather than NDSolve

Clear[g];
g[x_] = g[x] /.
DSolve[{g'[x] == Sin[x] + 2*With[{t = a*x}, Refine[f[t], 0 <= t < 10]],
g == 5}, g[x], x][]


-95 + 10 x + Cos - Cos[x]

Plot[f[x], {x, 0, 11}, AxesOrigin -> {0, 0}] 