我有一个立方体,其中我有异常的东西,将其视为零的立方体,我使用以下代码在其中放置一个较小的数字立方体:
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图中查看它,我可以看到它的异常。我该怎么办?
答案 0 :(得分:1)
转到isosurface
。使用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