【问题标题】:Matlab Convhull Error. Not enough unique data pointMatlab Convhull 错误。没有足够的唯一数据点
【发布时间】:2018-06-20 06:01:03
【问题描述】:

当我试图计算一组由圆内接的数字的凸包时,我在 Matlab 中收到了这个错误。这是代码,我一直得到的错误是:计算凸包时出错。指定的唯一点数不足。

for u = 1:50; 
  for v = 1:50;       
    if sqrt(((u-25)^2)+((v-25)^2)) <= 25
      c = convhull(u,v);
      plot(u(c),v(c),'r-',u,v,'b*')         
    end
  end
end

内接点或圆上的点:

【问题讨论】:

    标签: matlab convex-hull


    【解决方案1】:

    在您的代码中,您将单个点发送到convhull。而是先确定集合中的所有点,然后一次将它们全部发送到函数。这是一个例子。

    % create mesh
    [u,v] = meshgrid(1:50,1:50);
    % get indicies of points within the circle
    idx = sqrt((u-25).^2+(v-25).^2) <= 25;
    % filter outside points
    u = u(idx);
    v = v(idx);
    % compute convex hull
    c = convhull(u,v);
    plot(u(c),v(c),'r-',u,v,'b.');
    

    结果


    旁注:正式为a singleton set is convex,因此它是它自己的凸包。我不确定为什么 MathWorks 决定在这种情况下返回错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多