load data1.mat
load centroids.mat
x=data1(:,1)-centroids(:,1);
y=data1(:,2)-centroids(:,2);
[theta,r] = cart2pol(x,y);
r(end+1) = r(1);
theta(end+1) = theta(1);
[theta_sorted,ind] = sort(theta);
r_sorted = r(ind);
[theta_unique,IA,IC] = unique(theta_sorted);
r_unique = r_sorted(IA);
n = 360;
theta_n = linspace(min(theta_unique),max(theta_unique),n);
r_n = interp1(theta_unique,r_unique,theta_n);
[xn,yn] = pol2cart(theta_n,r_n);
figure(1),plot(x,y,'b.',xn,yn,'o');grid
figure(2),polarplot(theta_n, r_n,'--r')
Best Answer