Plot3 to mesh. Need to speed up my code

1 次查看(过去 30 天)
dx
dx 2013-3-17
Hello everyone,
i would like to accelerate my matlab code. The aim is to set up an array X-Y-Z for meshing based on a pointcloud Px-Py-Pz (each is a vector). The points Px and Py are arranged in a specific pattern. (I hope you can see the figure). My current solution is not fast enough, because I need to use this code quite often:
plot3(Px, Py, Pz,'.')
x = unique(Px);
y = unique(Py);
[X,Y] = meshgrid(x,y);
aX = X(1, :);
aY = Y(:, 1);
for k = 1:length(Pz)
index_x = find(aX == Px(k));
index_y = find(aY == Py(k));
Z(index_x, index_y) = Pz(k);
end
toc
mesh(X,Y,Z)
Do you have any ideas how to accelerate this code? Is it really necessary to use unique for that?
Regards

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Point Cloud Processing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by