Getting divergence of a 3D pointcloud

2 次查看(过去 30 天)
Dylan
Dylan 2012-1-8
Hi All,
I am trying to get the divergence values of a 3D pointcloud scan and I am having troube fitting the data to the "divergence" function. I have a sample of position and vector values:
pos=[
76.8777310000000 48.4557610000000 -64.5356670000000
57.6735570000000 57.4872930000000 -68.8201290000000
6.32152900000000 65.5864330000000 -66.0213850000000
79.1429290000000 50.6963460000000 -69.9525910000000
63.6980360000000 56.9969980000000 -70.2472530000000
59.7197610000000 60.1693840000000 -74.0278550000000]
vec=[
0.394940000000000 0.737656000000000 0.544422000000000
0.202651000000000 0.833657000000000 0.500410000000000
0.0167880000000000 0.808301000000000 0.561047000000000
0.424063000000000 0.802266000000000 0.414878000000000
0.247707000000000 0.809888000000000 0.526833000000000
0.151668000000000 0.861146000000000 0.480130000000000]
x = pos(:,1); %extract the first column of data
y = pos(:,2); %extract the second column of data
z = pos(:,3); %extract the third column of data
u = vec(:,1);
v = vec(:,2);
w = vec(:,3);
Then when I try:
div = divergence(x,y,z,u,v,w);
I get the following error:
??? Error using ==> divergence at 55 U,V,W must all be a 3D arrays.
Could someone please help, it's probably my silly formatting problem, but I cannot seem to figure it out. Much Appreciated.
  1 个评论
Andrei Bobrov
Andrei Bobrov 2012-1-8
please read about function 'divergence' in MATLAB help: http://www.mathworks.com/help/techdoc/ref/divergence.html

请先登录,再进行评论。

回答(1 个)

Andrew Newell
Andrew Newell 2012-1-9
You have worse than a formatting problem, if your point cloud is, as the name implies, an irregularly spaced collection of points. The function divergence assumes that your points lie on a 3D grid. You will need to interpolate both pos and vec onto a grid before you can use divergence. Then you will need to use meshgrid to turn each coordinate x, u, etc. into a 3D array.

Community Treasure Hunt

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

Start Hunting!

Translated by