Conditionally cycle paths

When a path ends in a NaN, it should not be cycled as it is explicitly
broken in MATLAB, but it seems that `pgfplots` does not take NaNs into
account when closing the path.
Some issue links in ACID
Merge branch 'cyclePaths' to fix #317, #49, #404

Tested on R2014a, R2014b