找回密码
 注册
Simdroid-非首页
查看: 47|回复: 2

matlab如何对平面节点进行重新排序?

[复制链接]
发表于 2012-9-10 09:10:09 | 显示全部楼层 |阅读模式 来自 江苏南京
悬赏10仿真币已解决
本帖最后由 红黑22 于 2012-9-10 10:07 编辑

如在平面上由rand随机在[0,1]*[0,1]平面布置N个节点,我如何将这N个节点按照其节点x坐标从小到大而同时y坐标由
发表于 2012-9-10 09:10:10 | 显示全部楼层 来自 河北沧州
Simdroid开发平台
本帖最后由 liuyalong008 于 2012-9-10 20:05 编辑
  1. N=100;
  2. x=rand(N,1);
  3. y=rand(N,1);
  4. Points=[x,y];
  5. [D,Index]=sort(Points);
  6. scatter(Points(Index(:,1),1),Points(Index(:,1),2),5)
  7. set(get(gca,'child'),'MarkerFaceColor','r')
  8. arrayfun(@(i)text(Points(Index(i,1),1)+0.01,Points(Index(i,1),2),num2str(i)),1:length(D))
复制代码
回复

使用道具 举报

 楼主| 发表于 2012-9-11 16:40:22 | 显示全部楼层 来自 江苏南京
liuyalong008 发表于 2012-9-10 09:10

谢谢!原来我对这个matlab中还有好多数组函数不大了解啊
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-4-27 13:41 , Processed in 0.028668 second(s), 10 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表