Project about 3D point density

4 次查看(过去 30 天)
Matt
Matt 2014-11-19
编辑: Star Strider 2014-11-20
I have a school project where we are given a 1000-column, 3-row Excel file and told to organize it into 'boxes' in three dimensions then concentrate the points into the most dense z-box for each box on the bottom (25 since I chose to make 5x5x5 boxes). I then have to make a surface out of my 25 density points. I have made three functions that mostly complete the problem.
Data='Data.xlsx';
num=xlsread(Data);
x=num(1:size(num),1);
y=num(1:size(num),2);
z=num(1:size(num),3);
minx=min(x);
miny=min(y);
minz=min(z);
maxx=max(x);
maxy=max(y);
maxz=max(z);
xinc=linspace(minx,maxx,6);
yinc=linspace(miny,maxy,6);
zinc=linspace(minz,maxz,6);
First one reads the file and gets basic info such as the minimum and maximum values.
incx=xinc(2)-xinc(1);
incy=yinc(2)-yinc(1);
incz=zinc(2)-zinc(1);
spaces=zeros(25,1);
grnd=zeros(25,5);
for i=1:size(num)
m=ceil((num(i,1)-minx)/incx);
if m==0
m=1;
elseif m==6
m=5;
end
n=ceil((num(i,2)-miny)/incy);
if n==0
n=1;
elseif n==6
n=5;
end
p=ceil((num(i,3)-minz)/incz);
if p==0
p=1;
elseif p==6
p=5;
end
grnd(m+5*(n-1),p)=grnd(m+5*(n-1),p)+1;
end
for j=1:25
[g h]=max(grnd(j,1:5));
space(j,1)=h;
end
This one finds the density of points. I'm most worried about this as values at the absolute minimum or maximum would give values outside 1:5, so I set any 0 value to 1 and 6 values to 0. Seems dubious, but I couldn't think of another way to fix it. Let me know if this could cause problems and suggest ways to fix it.
xboxes=linspace(16.309,18.701,5);
yboxes=linspace(35.149,75.861,5);
zboxes=linspace(11.309,13.701,5);
for i=1:5
for j=1:5
plot3(x(i,1),y(j,1),z(space((i+5*(j-1)),1)))
hold on
end
end
grid on
This plots the 25 points I found. I've tested these functions and it works until now, but I can't figure out how to make a surface of the points without messing up my data. Once I can do that (and maybe optimize the second function), I'm done. Any suggestions? Thanks in advance. I have included the Excel file in this post.
  2 个评论
Image Analyst
Image Analyst 2014-11-19
It sure would be a heck of a lot easier for people to help you if you attached 'Data.xlsx'.
Matt
Matt 2014-11-19
Sorry, I thought I did. It should be there now.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by