0
我有一个结构阵列,如:在它如何在MATLAB中测试结构数组的成员资格?
points(1).x = 3
points(1).y = 4.5
points(1).z = 1
...
points(n).x = 2
points(n).y = 23
points(n).z = 4
现在给定的三个坐标(X,Y,Z),我想
points = struct('x',[],'y',[],'z',[])
点多到现在,如果有这样的指向points
。因此,我已经定义了以下功能:
function true_or_false = is_in(points, point)
for i = 1:numel(points)
if abs(points(i).x - point.x) < 1e-7 && ...
abs(points(i).y - point.y) < 1e-7 && ...
abs(points(i).z - point.z) < 1e-7
true_or_false = true;
return
end
end
true_or_false = false;
end
的问题是,这是非常低效的。有一个更好的方法吗?也许使用别的东西而不是结构?
您是否要求[代码评论](http://codereview.stackexchange.com/)? –
我在寻求解决问题的有效方法。 – IIIaxS