Reputation: 1
I have a cube in which I have something as a anomaly, consider it as a cube of zeros and I put a smaller cube of numbers in it using the following code:
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
I want to somehow view it in a 3D figure, for which I can see the anomaly it it. How can I do it?
Upvotes: 0
Views: 252
Reputation: 35525
Go for isosurface
. With isosurface you will be able to extract the inclusion. If you also want to show the whole box, I recommend you to do the following: Create a small box (so it has few faces when converted to isosurface) and then scale it to the real size of the box. You can see this in the following code:
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
Upvotes: 1