If you have definite coordinates for the endpoints of the line then its length can be calculated with the Euclidean formula. But you probably don't need it.
Divide the total change in x by the number of segments, and the total length in y by the number of segments, and record those. Now divide both of those by 2 and add those half-values to the original endpoint coordinates. The result will be the middle of the first segment. After that, add the whole deltas successively to get the middles of the additional segments.
If the circles are to go through the endpoints of each segment, then the centers are the middles I just described and the radii is the length of the half-change:
n = 10;
deltax = (x(2) - x(1))/n;
deltay = (y(2) - y(1))/n;
halfdx = deltax/2;
halfdy = deltay/2;
radius = sqrt(halfdx.^2 + halfdy.^2);
xcents = x(1) + halfdx + (0:n-1)*deltax;
ycents = y(1) + halfdy + (0:n-1)*deltay;
plot(x, y, 'bs', xcents, ycents, 'r*');
Best Answer