📄 pca_fuzzy_c-means_method.txt
字号:
load ushape.dat
%perfomring PCA
[pcs,newdata,variances,t2] = princomp(ushape);
percent_explained = 100*variances/sum(variances)
%plot Pareto
subplot(3,3,1)
pareto(percent_explained)
title('Pareto plot')
xlabel('Principal Component')
ylabel('Variance Explained (%)')
%plot PC1-PC2
subplot(3,3,2)
line(newdata(:, 1), newdata(:, 2), 'linestyle',...
'none','marker', 'd','color','b');
title('PC1-PC2 two dimension plot')
xlabel('PC1')
ylabel('PC2')
%fuzzy c-means clustering
n=input('Enter the number of clusters wanted:')
m=input('Enter the number of PCs are wanted:')
[center,U,objFcn] =fcm(newdata(:,1:m),n);
maxU = max(U);
for k=1:1:n
index(k) = {find(U(k, :) == maxU)};
end
subplot(3,3,3)
linecolor='rgbcmyk';
pointmark='dox+*sv^<>ph';
for k=1:1:n
line(newdata(index{k}, 1), newdata(index{k}, 2), 'linestyle','none','marker', pointmark(k),'color',linecolor(k));
end
hold on
for k=1:1:n
plot(center(k,1),center(k,2),strcat('k',pointmark(k)),'markersize',15,'LineWidth',2)
end
title('Fuzzy c-means clustering')
xlabel('PC1')
ylabel('PC2')
[row1,col1]=size(ushape)
for k=1:1:n
[row2,col2]=size(index{k})
cluster(k)={[]}
for p=1:1:col2
cluster(k)={[cluster{k};ushape(index{k}(p),1:col1)]}
end
end
%
%for k=1:1:n
% subplot(3,3,3+k)
% hist (cluster{k},3)
% xlabel('Springback Angle')
% %ylabel('normal probability density')
% title(strcat('cluster',int2str(k)))
%end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -