MATLAB: How to remove the connection between head and end?

3d plotsMATLAB

Why is the data at the end of the first group and the beginning of the second group connected?
using
plot3
and codes are as this
clc;
clear all;
close all;
x=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100];
y=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98];
z=[1.80100000000000,1.80100000000000,1.80100000000000,1.80100000000000,1.80100000000000,1.80100000000000,1.80100000000000,1.51350000000000,1.22600000000000,0.761700000000000,0.297400000000000,0.301820000000000,0.306240000000000,0.310660000000000,0.315080000000000,0.319500000000000,0.384520000000000,0.449540000000000,0.514560000000000,0.579580000000000,0.644600000000000,0.651210000000000,0.657820000000000,0.664430000000000,0.671040000000000,0.677650000000000,0.684260000000000,0.690870000000000,0.697480000000000,0.704090000000000,0.710700000000000,0.717310000000000,0.723920000000000,0.730530000000000,0.737140000000000,0.743750000000000,0.750360000000000,0.756970000000000,0.763580000000000,0.770190000000000,0.776800000000000,0.772470000000000,0.768140000000000,0.763810000000000,0.759480000000000,0.755150000000000,0.750820000000000,0.746490000000000,0.742160000000000,0.737830000000000,0.733500000000000,0.729170000000000,0.724840000000000,0.720510000000000,0.716180000000000,0.711850000000000,0.707520000000000,0.703190000000000,0.698860000000000,0.694530000000000,0.690200000000000,0.689172500000000,0.688145000000000,0.687117500000000,0.686090000000000,0.685062500000000,0.684035000000000,0.683007500000000,0.681980000000000,0.680952500000000,0.679925000000000,0.678897500000000,0.677870000000000,0.676842500000000,0.675815000000000,0.674787500000000,0.673760000000000,0.672732500000000,0.671705000000000,0.670677500000000,0.669650000000000,0.668622500000000,0.667595000000000,0.666567500000000,0.665540000000000,0.664512500000000,0.663485000000000,0.662457500000000,0.661430000000000,0.660402500000000,0.659375000000000,0.658347500000000,0.657320000000000,0.656292500000000,0.655265000000000,0.654237500000000,0.653210000000000,0.652182500000000,0.651155000000000,0.650127500000000,0.649100000000000,1.80189517610261,1.80189517610261,1.80189517610261,1.80189517610261,1.80189517610261,1.80189517610261,1.80189517610261,1.51512706940405,1.22835896270549,0.764058963224847,0.299758963744208,0.304404955454506,0.309050947164803,0.313696938875101,0.318342930585399,0.322988922295697,0.387740625947457,0.452492329599217,0.517244033250977,0.581995736902736,0.646747440554496,0.653337634980550,0.659927829406603,0.666518023832656,0.673108218258709,0.679698412684762,0.686288607110815,0.692878801536868,0.699468995962921,0.706059190388974,0.712649384815027,0.719239579241080,0.725829773667133,0.732419968093186,0.739010162519239,0.745600356945292,0.752190551371345,0.758780745797398,0.765370940223451,0.771961134649504,0.778551329075558,0.774223775875059,0.769896222674561,0.765568669474063,0.761241116273565,0.756913563073067,0.752586009872569,0.748258456672071,0.743930903471573,0.739603350271075,0.735275797070577,0.730948243870079,0.726620690669581,0.722293137469083,0.717965584268585,0.713638031068087,0.709310477867589,0.704982924667091,0.700655371466593,0.696327818266095,0.692000265065597,0.690967196710666,0.689934128355736,0.688901060000805,0.687867991645875,0.686834923290945,0.685801854936014,0.684768786581084,0.683735718226153,0.682702649871223,0.681669581516293,0.680636513161362,0.679603444806432,0.678570376451501,0.677537308096571,0.676504239741641,0.675471171386710,0.674438103031780,0.673405034676849,0.672371966321919,0.671338897966989,0.670305829612058,0.669272761257128,0.668239692902197,0.667206624547267,0.666173556192337,0.665140487837406,0.664107419482476,0.663074351127545,0.662041282772615,0.661008214417685,0.659975146062754,0.658942077707824,0.657909009352894,0.656875940997963,0.655842872643033,0.654809804288102,0.653776735933172,0.652743667578241];
figure(1)
plot3(x,y,z)
so how to delete the Extra lines?

Best Answer

idx = find(x>0,1);
X = [x(1:idx-1), nan, x(idx:end)];
Y = [y(1:idx-1), nan, y(idx:end)];
Z = [z(1:idx-1), nan, z(idx:end)];
plot3(X, Y, Z)