小编Vik*_*ram的帖子

计算区域中所有点的距离

我有一个约144分的地区.我想要实现的是测量点与所有其他点的距离并将其存储在数组中.我想为所有要点做这件事.如果可能的话,我希望以不重复的方式存储这些数据.而且我应该可以进行如下查询:所有点之间的所有距离都不重复,点56的所有距离之和等等.

我有一个3*144阵列,有两列存储点的坐标.

matlab distance matrix

7
推荐指数
1
解决办法
9788
查看次数

matlab代码的矢量化

我对矢量化有点新意.已经尝试过但不能.有人可以帮助我对这段代码进行矢量化,并简要说明你是如何做到这一点的,这样我就可以适应思维过程.谢谢.

function [result] = newHitTest (point,Polygon,r,tol,stepSize)
%This function calculates whether a point is allowed.

%First is a quick test is done by calculating the distance from point to 
%each point of the polygon. If that distance is smaller than range "r", 
%the point is not allowed. This will slow down the algorithm at some 
%points, but will greatly speed it up in others because less calls to the 
%circleTest routine are needed.
polySize=size(Polygon,1);
testCounter=0;

for i=1:polySize
d = sqrt(sum((Polygon(i,:)-point).^2));

if …
Run Code Online (Sandbox Code Playgroud)

optimization performance matlab vectorization

4
推荐指数
1
解决办法
314
查看次数

可以进行矢量化吗?会有什么好处吗?

这个功能在我的跑步中吃了很多时间.但是看到的是内置功能的大部分时间polyarea.这段代码可以进行矢量化以提升性能吗?

Profiler报告 -

  time   calls
                  1 function [S S_area] = Polygons_intersection_Compute_area(S)
                  2 % Guillaume JACQUENOT
                  3 % guillaume at jacquenot at gmail dot com
                  4 % 2007_10_08
                  5 % 2009_06_16
                  6 % Compute area of each polygon of in S.
                  7 % Results are stored as a field in S
                  8 
  0.50   51945    9 S_area = struct('A', {}); 
  0.20   51945   10 for i=1:numel(S) 
  0.28  103890   11     S(i).area = 0; 
  1.34  103890   12     S_area(i).A = zeros(1,numel(S(i).P)); 
  0.69  103890   13 …
Run Code Online (Sandbox Code Playgroud)

performance matlab vectorization

1
推荐指数
1
解决办法
97
查看次数