It is difficult to draw a closed polar coordinate curve.
load data1.mat
x=data1(:,1);y=data1(:,2);
hold on
plot(centroids(:,1),centroids(:,2),'b*')
[x y]=data1;
[theta,r] = cart2pol(x,y);
% closing the circle
r(end+1) = r(1);
theta(end+1) = theta(1);
% convert to cartesian
[x,y] = pol2cart(theta,r);
% interpolate with parameter t
t = (1:n)';
v = [x,y];
tt = linspace(1,n,100);
X = interp1(t,v,tt,'pchip');
% plot
plot(x,y,'o');
hold on
plot(X(:,1),X(:,2));
Best Answer