我想绘制三维矩阵的每个切片,以显示第三维的差异。然而,我只能设法将它们绘制在彼此之外,并且我想要一个3d图,其中显然矩阵的切片实际上是堆叠的。到目前为止我的两层代码是
visualmatrix=zeros(10);
visualmatrix(1:5,1:5)=1;
visualmatrix2=zeros(10);
visualmatrix2(1:8,1:8)=1;
subplot(1,2,1)
[r,c] = size(visualmatrix); %# Get the matrix size
imagesc((1:c)+0.5,(1:r)+0.5,-visualmatrix); %# Plot the image
colormap(gray); %# Use a gray colormap
axis equal %# Make axes grid sizes equal
set(gca,'XTick',1:(c+1),'YTick',1:(r+1),... %# Change some axes properties
'XLim',[1 c+1],'YLim',[1 r+1],...
'GridLineStyle','-','XGrid','on','YGrid','on');
subplot(1,2,2)
[r,c] = size(visualmatrix2); %# Get the matrix size
imagesc((1:c)+0.5,(1:r)+0.5,-visualmatrix2); %# Plot the image
colormap(gray); %# Use a gray colormap
axis equal %# Make axes grid sizes equal
set(gca,'XTick',1:(c+1),'YTick',1:(r+1),... %# Change some axes properties
'XLim',[1 c+1],'YLim',[1 r+1],...
'GridLineStyle','-','XGrid','on','YGrid','on');
colorbar
colorbar('Ticks',[-1,0],...
'TickLabels',{'Equal','Different'})
suptitle('Illustration of the concept')
这导致以下图像
是否有一种简单的方法可以在3d图中将其显示为5层? 提前谢谢。