Getting divergence of a 3D pointcloud
Show older comments
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 Comment
Andrei Bobrov
on 8 Jan 2012
please read about function 'divergence' in MATLAB help: http://www.mathworks.com/help/techdoc/ref/divergence.html
Answers (1)
Andrew Newell
on 9 Jan 2012
1 vote
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.
Categories
Find more on Matrix and Vector Construction in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!