[英]Plotting a 3d matrix in slices - MATLAB
I would like to plot each slice of my 3d matrix to show differences across the third dimension. 我想绘制3D矩阵的每个切片,以显示第三维的差异。 However I can only manage to plot them besides each other, and I would like a 3d plot where it is clear that the slices of the matrix are in fact stacked. 但是,我只能将它们彼此绘制在一起,并且我想要一个3d图,其中很明显矩阵的切片实际上是堆叠的。 My code for two layers so far is 到目前为止,我的两层代码是
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')
Which leads to the following image 这导致下图
Is there a simple way to make it visualize this in a 3d plot with ie 5 layers? 有没有一种简单的方法可以使其在3层绘图(即5层)中可视化? Thank you in advance. 先感谢您。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.