① 用matlab mpt工具箱生成受限的voronoi图。请问该怎么得到各个顶点坐标呢(包括voronoi边与边界的交点)
extreme这个函数就可以得到顶点坐标。
给你个代码:
function irPoly = getIrreg(m,s)
%GETIRREGULAR Summary of this function goes here
% get irregular pixels
% the same begin & end
% clockwise order
% m - regular size
% S - low/high resolution
% get limit voronoi
x = gallery('uniformdata', [(m*s)^2 1], 0);
y = gallery('uniformdata', [(m*s)^2 1], 1);
vOut = [0,0; 0,m; m,m; m,0];
P = polytope(vOut);
Options.pbound = P;
% Options.plot = 1;
Pn = mpt_voronoi(m*[x,y],Options);
% split each polygon
for iPoly = 1:length(Pn)
thisPoly = extreme(Pn(iPoly));
% limited in [0,m]
thisPoly(thisPoly>m) = m;
thisPoly(thisPoly<0) = 0;
% make points in order
k = convhull(thisPoly(:,1), thisPoly(:,2));
% make clockwise
[pX,pY] = poly2cw(thisPoly(k,1),thisPoly(k,2));
irPoly{iPoly} = [pX,pY];
end%for iPoly
end%function
② matlab中如何给voronoi加个边界
代码如下
A=[100*rand(10,2)rand(10,1)];
pbound=polytope([000;15000;1501500;01500;001;15001;1501501;01501]);
Options.pbound=pbound;
Options.plot=1;
mpt_voronoi(A,Options);
③ 求2014a版的matlab中MPT工具箱
留个邮箱,我给你发到邮箱里边去。
④ Matlab的MPT工具箱
^extreme这个函数就可以得到顶点坐标。 给你个代码: function irPoly = getIrreg(m,s) %GETIRREGULAR Summary of this function goes here % get irregular pixels % the same begin & end % clockwise order % m - regular size % S - low/high resolution % get limit voronoi x = gallery('uniformdata', [(m*s)^2 1], 0); y = gallery('uniformdata', [(m*s)^2 1], 1); vOut = [0,0; 0,m; m,m; m,0]; P = polytope(vOut); Options.pbound = P; % Options.plot = 1; Pn = mpt_voronoi(m*[x,y],Options); % split each polygon for iPoly = 1:length(Pn) thisPoly = extreme(Pn(iPoly)); % limited in [0,m] thisPoly(thisPoly>m) = m; thisPoly(thisPoly<0) = 0; % make points in order k = convhull(thisPoly(:,1), thisPoly(:,2)); % make clockwise [pX,pY] = poly2cw(thisPoly(k,1),thisPoly(k,2)); irPoly{iPoly} = [pX,pY]; end%for iPoly end%function
⑤ 请问怎么用matlab画voronoi图,能否提供mpt_voronoi工具箱
⑥ matlab中生成voronoi图时,能否设定一个边界使得voronoi顶点不出现无穷远点
下个mpt工具箱
里面的_voronoi可以实现你的要求
MPT_VORONOI Computes the voronoi diagram via mpLP
[Pn]=mpt_voronoi(points,Options)
---------------------------------------------------------------------------
DESCRIPTION
---------------------------------------------------------------------------
The voronoi diagram is a partition of the state space; For a given set of
points pj, each region Pn(j) is defined as
Pn(j)={x \in R^n | d(x,pj)<=d(x,pi), \forall i \neq j}
---------------------------------------------------------------------------
INPUT
---------------------------------------------------------------------------
points - Optional input:
Matrix p times nx of points: nx is state space dimension and
p is the number of points
The entry is graphical in 2D if no parameters are passed.
Options.pbound - A "bounding polytope". If provided, the voronoi cells will
be bounded by this polytope. If not provided, the cells will
be bounded by a hypercube as big as 1.5x the maximum
coordinate of any of the seed points
Options.plot - If set to 1, plots the voronoi diagram (0 is default)
Options.sortcells - If set to 1, resulting Voronoi partition will be ordered
in a way such that Pn(i) corresponds to seed point i.
(Default is 1)
⑦ MATLAB的MPT工具箱如何安装,按照官网教程总是出错
matlab的工具箱安装其实很简单, 说白了就是设置一个路径让Matlab能找到工具箱里面的东西
方法是:
下载版工具箱
解压缩到一权个目录(任意的,随便你放哪里)
在File -> Set Path 里面把第2步的那个目录加到系统路径里面, 第二个按键 Add with Subfolders (见下图)
回到matlab命令行: 输入DemoPSOBehavior 不出错就成功了!
⑧ 用matlab画有边界的voronoi图,怎么画
估计你是刚刚加载吧,提示说MATLAB找不到路径,我当初加载神经网络的时候,和你的处境一样,我关了MATLAB,吃完饭一用,神奇的好了。望采纳。
⑨ matlab中生成voronoi图时,能否设定一个边界使得voronoi顶点不出现无穷远点
下个mpt工具箱
里面的mpt_voronoi可以实现你的要求
MPT_VORONOI Computes the voronoi diagram via mpLP
[Pn]=mpt_voronoi(points,Options)
---------------------------------------------------------------------------
DESCRIPTION
---------------------------------------------------------------------------
The voronoi diagram is a partition of the state space; For a given set of
points pj, each region Pn(j) is defined as
Pn(j)={x \in R^n | d(x,pj)<=d(x,pi), \forall i \neq j}
---------------------------------------------------------------------------
INPUT
---------------------------------------------------------------------------
points - Optional input:
Matrix p times nx of points: nx is state space dimension and
p is the number of points
The entry is graphical in 2D if no parameters are passed.
Options.pbound - A "bounding polytope". If provided, the voronoi cells will
be bounded by this polytope. If not provided, the cells will
be bounded by a hypercube as big as 1.5x the maximum
coordinate of any of the seed points
Options.plot - If set to 1, plots the voronoi diagram (0 is default)
Options.sortcells - If set to 1, resulting Voronoi partition will be ordered
in a way such that Pn(i) corresponds to seed point i.
(Default is 1)