基于Matlab实现空间数据的主成分局部均值聚类

✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。

🍎个人主页:Matlab科研工作室

🍊个人信条:格物致知。

更多Matlab仿真内容点击👇

智能优化算法  神经网络预测 雷达通信  无线传感器

信号处理 图像处理 路径规划 元胞自动机 无人机  电力系统

⛄ 内容介绍

​从理论,设计程序和代码实现等方面,说明如何通过数据挖掘中K-均值聚类算法,利用Matlab的灵活编程功能进行探索性和优化性综合实验.以实验教学实践说明,为将创新思维和动手能力培养贯穿于实验教学的始终,利用Matlab仿真K-均值聚类具有较好的实际意义.

⛄ 部分代码

close all

disp(' ')

disp('This DEMO simulates 2D-3D spatial data {Xi,Yi,Zi} and computes their')

disp('principal curves and surfaces by means of local clustering techniques.')

disp('These methods are based on iterative projections of local simple means')

disp('made by the principal components (PC) of the local covariance matrices.')

disp('The archive contains 5 programs:')

disp('1) PCLM_estimate: computes principal curves in 2D an surfaces in 3D,')

disp('2) PCLM_select_n: identifies the optimal size "n" of means and cov,')

disp('3) PCLM_select_k: identifies the optimal number "k" of iterations,')

disp('4) PCLM_slice_3d: estimates 3d surfaces by layers of 2d curves,')

disp('5) PCLM_adaptive: as in 1) but with k-varying coefficient n.')

disp(' ')

disp('Press enter to continue ...')

disp(' ')

disp('Data generation:') 

disp('882 points of two intesecting planes are simulated and randomized')

disp('Wait while computing ... ')

rng('default')

[x y] = meshgrid(-10:1:10);

Z1 = 1*x + 50*y + 500; figure; subplot(221); surf(x,y,Z1/100)

Z2 = 1*x - 50*y + 500; hold on; surf(x,y,Z2/100); axis tight

title('Ground surfaces')

n=length(x(:)); a=1;

xx=x(:)+randn(n,1)*a; 

yy=y(:)+randn(n,1)*a; 

z1=Z1(:)/100+randn(n,1)*a; 

z2=Z2(:)/100+randn(n,1)*a;

subplot(222)

plot3(yy,z1,xx,'.b'); grid; hold on

plot3(yy,z2,xx,'.r'); box; axis tight

xlabel('x'); ylabel('y'); zlabel('z')

title('Randomized points')

XYZ=[[yy z1 xx]; [yy z2 xx]];

disp(' ')

disp('Press enter to continue ...')

disp(' ')

disp('2D fitting of data with heuristic selection of coefficients:')

disp('YY = PCLM_estimate( [XYZ ones(n*2,1)], 2,1,2, 40,1,6, 1);')

      YY = PCLM_estimate( [XYZ ones(n*2,1)], 2,1,2, 40,1,6, 1);

disp(' ')

disp('Press enter to continue ...')

disp(' ')

disp('3D fitting of data with 2D selection of nearest neighbors:')

disp('YY = PCLM_estimate( [XYZ ones(n*2,1)], 3,1,2, 40,1,6, 1);')

      YY = PCLM_estimate( [XYZ ones(n*2,1)], 3,1,2, 40,1,6, 1);

disp(' ')

disp('Press enter to continue ...')

disp(' ')

disp('Tentative selection of the optimal number "n" of neighbors in 2D')

disp('PCLM_select_n( [XYZ ones(n*2,1)], 2,1,2,  1,6,  15,90,6, 1 );')

      PCLM_select_n( [XYZ ones(n*2,1)], 2,1,2,  1,6,  15,90,6, 1 );

disp(' ')

disp('Press enter to continue ...')

disp(' ')

disp('Tentative selection of the optimal number "k" of iterations in 2D')

disp('PCLM_select_k( [XYZ ones(n*2,1)], 2,1,2, 40,1,9, 1 );')

      PCLM_select_k( [XYZ ones(n*2,1)], 2,1,2, 40,1,9, 1 );

disp(' ')

disp('Press enter to continue ...')

disp('Finally, run a sliced 3D fitting with 2D sequential curves ...')

disp('PCLM_slice_3d( [XYZ ones(n*2,1)], 20,1,6, 3,50,4 );')

      PCLM_slice_3d( [XYZ ones(n*2,1)], 20,1,6, 3,50,4 );

disp(' ')

disp('Press enter to continue ...')

disp(' ')

disp('Also, run the adaptive version of the basic code ...')

disp('with proportional distance weighting of the local statistics')

disp('and decreasing value of the sample size during the iterations')

disp('PCLM_adaptive( [XYZ ones(n*2,1)], 2,1,2,  100,1,10,  2,-9, 1 );')

      PCLM_adaptive( [XYZ ones(n*2,1)], 2,1,2,  100,1,10,  2,-9, 1 );

disp(' ')

disp('bye :-)')

⛄ 运行结果

⛄ 参考文献

[1]陈璐, 汪亚明, 韩永华. 基于子空间K均值聚类的概率配准算法[J]. 软件导刊, 2021.

⛄ 完整代码

❤️部分理论引用网络文献,若有侵权联系博主删除

❤️ 关注我领取海量matlab电子书和数学建模资料

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

matlab科研助手

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值