there are two matrix O1 and O2 of the same size 1 line and 5 columns, o1 o2 represante X and Y which represante 5 is obtained point-ordinates (o1 (i), a2 (j)) we will calcuer the disstance between all the points, and if lower 30 esy must make a line between them .I have problem in the code that can help me and thank you here is the code
o1 =[30 38 29 68 39]o2 =[109 29 24 75 97]plot(o1,o2,'^','LineWidth',1,... 'MarkerEdgeColor','k',... 'MarkerFaceColor','y',... 'MarkerSize',12);hold on%calculate the distance between the point
for i=1:4 for j=1:4 % % d=sqrt[(x2-x1).^2 + (y2-y1).^2]
d(i,j)=sqrt([o1(i+1)-o1(i)].^2 + [o2(j+1)-o2(j)].^2) i==i+1; j==j+1; endend % to test the value of and created a line if d <30
for i=1:4 for j=1:4 if d(i,j)<=30 line(o1(i),o2(j)) end endend
Best Answer