No products are associated with this question.
dx = 0.01; x = (0:dx:10-dx)';
idx = (x < 5);
C = ... D = ...
z = ( C + x.^2 / 2 ) .* idx + ( D + x.^3 / 3 ) .* ( 1 - idx ) ;
You will need to specify values for the constant C and D based on the initial value of z and the continuity condition at x = 5.