怎么把MATLAB生成的voronoi图里面的点去掉
时间: 2023-05-31 21:04:29 浏览: 204
要去掉MATLAB生成的Voronoi图中的点,可以使用以下方法:
1. 使用“hold on”命令将图形保持在同一窗口中,并使用“scatter”命令在该图形中绘制点。
2. 在使用“voronoi”命令生成Voronoi图时,设置输出参数为“[vx,vy]”,然后使用“plot”命令绘制Voronoi图的边界。
3. 最后使用“axis off”命令关闭坐标轴,以便只显示Voronoi图的边界。
下面是一个示例代码:
```
% 生成随机点集
x = rand(1,10);
y = rand(1,10);
% 使用scatter命令绘制点
scatter(x,y,'filled');
% 使用voronoi命令生成Voronoi图
[vx,vy] = voronoi(x,y);
plot(vx,vy,'k-','LineWidth',2);
% 关闭坐标轴
axis off;
```
运行该代码后,您将在MATLAB图形窗口中看到一个Voronoi图,其中包含随机生成的点和Voronoi图的边界,而没有其他多余的点。
相关问题
matlab生成voronoi图
Voronoi图,也称泰森多边形,是地理信息系统和计算机科学领域中非常常见的一种图形表达方式。其本质是将平面空间划分为若干个由特定点向外拓展的区域,这些区域相互联系构成了一个具有一定特点的图形。
在MATLAB中生成Voronoi图非常简单,只需要使用voronoi函数即可完成。其使用方法如下:
1.首先需要确定要生成Voronoi图的点,可以通过手动输入坐标或从其他文件中导入。以手动输入为例,可以将X和Y坐标保存在两个矩阵中。
2.在命令行窗口中输入[vx,vy] = voronoi(X,Y),其中vx和vy表示生成Voronoi图之后的顶点坐标。
3.使用plot函数进行绘图。可以使用hold on和hold off命令来保留图形,方便后续添加其他图层。例如,plot(vx,vy,'k-',X,Y,'r.')命令表示绘制Voronoi图和原始点的坐标,其中k-和r.分别表示绘制线段和点。
通过以上步骤,就可以在MATLAB中生成Voronoi图了。其中,生成的Voronoi图可能包含无限长度的线段,需要使用xlim和ylim函数根据实际情况调整坐标轴范围。同时,也可以使用fill函数来填充各个区域的颜色,增强图形的可视化效果。
写出matlab生成voronoi图的代码
以下是生成voronoi图的matlab代码:
x = rand(1,50);
y = rand(1,50);
[vx,vy] = voronoi(x,y);
plot(x,y,'.',vx,vy,'-');
axis equal
希望对你有帮助。
阅读全文
相关推荐













