2014-10-27 62 views
0

我有一個立方體中,我有一些作爲異常立方體的3D觀看,認爲這是零的立方體和我使用下面的代碼把數字的小方塊在它:放在另一個一個

anomaly = zeros(100,100,100); 

for j = 40:60 
    for jj = 40:60 
     for jjj=40:60 
      anomaly(j,jj,jjj)=10; 
     end 
    end 
end 

我想以某種方式查看它的3D圖,爲此我可以看到它的異常。我該怎麼做?

回答

1

前往isosurface。藉助等值面,您將能夠提取包含。如果您還想顯示整個盒子,我建議您執行以下操作:創建一個小盒子(因此在轉換爲等值面時它的面孔很少),然後將其縮放到盒子的實際大小。您可以在下面的代碼中看到這一點:

anomaly = zeros(100,100,100);    % The anomaly 
an2=zeros(100/10+2,100/10+2,100/10+2);  % For plotting pourposes 
an2(2:10,2:10,2:10)=1;      % Create a 10x10x10 box 
for j = 40:60 
    for jj = 40:60 
    for jjj=40:60 
     anomaly(j,jj,jjj)=10; 
    end 
    end 
end 
iso=isosurface(anomaly,5);     % Extract surface of inclusion 
iso2=isosurface(an2,0.5);     % create a box 
iso2.vertices=(iso2.vertices-1)*10;   % offset(so its in 1-10 range) 
              % and scaling to be 100x100x100 
patch(iso,'facecolor','r','edgecolor','none') 
patch(iso2,'facecolor','none'); 
% this last ones are for having a nicer plot 
camlight 
axis off 
axis equal 

enter image description here

+0

表面可以是透明的?我想看看內在的包容。 – sabaaa 2014-10-28 09:38:15

+0

@sabaaa這實際上是內在包容。讓我編輯答案。 – 2014-10-28 09:59:06

+0

@sabaaa現在呢?它正在爲你的數據工作? – 2014-10-28 16:32:46

相關問題