I am attempting to do a phase plot for a driven,damped pendulum. When the angle wraps from Pi to -Pi or -Pi to Pi I get a horizontal line on the plot. I would like to remove these lines as they mask the structure that is evident when plotting chaotic orbits. The function sss[t] performs the angle wrap and uses the piecewise function. Also I wanted to post the plot along with this question but could not find information on how to do it.
s = NDSolve[{\[Theta]''[t] + .5 \[Theta]'[t] + Sin[\[Theta][t]] ==
1.35 Sin[2/3 t], \[Theta][0] == Pi/4, \[Theta]'[0] == 0}, {\[Theta],
\[Theta]'}, {t, 0, 10000}];
ss[t_] := Flatten[{\[Theta][t]} /. s]
sss[t_] := Piecewise[{{Mod[ss[t][[1]], 2 Pi] - 2 Pi,
Mod[ss[t][[1]], 2 Pi] > Pi && ss[t][[1]] >= 0}, {Mod[ss[t][[1]],
2 Pi], Mod[ss[t][[1]], 2 Pi] < Pi &&
ss[t][[1]] >= 0}, {-(Mod[-ss[t][[1]], 2 Pi] - 2 Pi),
Mod[-ss[t][[1]], 2 Pi] > Pi &&
ss[t][[1]] < 0}, {-(Mod[-ss[t][[1]], 2 Pi]),
Mod[-ss[t][[1]], 2 Pi] < Pi && ss[t][[1]] < 0}, {ss[t][[1]], -Pi
<= ss[t][[1]] <= Pi}}]
ParametricPlot[Evaluate[{sss[t], \[Theta]'[t]} /. s], {t, 800, 1000},
PlotRange -> 3]





Exclusionswith conditions ont. You need to find the values oftwhere the function is discontinuous. UsingNDSolveValueshould also simplify things. Don't return boththetaandtheta'fromNDSolveValue.thetais sufficient, you can take the derivative later. See also if the third argument ofModcan simplify yourPiecewise. – Szabolcs Apr 02 '15 at 01:57