如何在 2D 中绘制 3D 矩阵?

How could one plot 3D matrix in 2D?

我是 matlab 编码的新手。我有以下 3D 矩阵

>> Xc
Xc(:,:,1) =

   -1.6803   -1.6803   -1.6803   -1.6803        
   -1.1803   -1.1803   -1.1803   -1.1803         
   -0.6803   -0.6803   -0.6803   -0.6803        
  -14.1803  -14.1803  -14.1803  -14.1803         
Xc(:,:,2) =

   -1.6803   -1.6803   -1.6803   -1.6803         
   -1.1803   -1.1803   -1.1803   -1.1803         
   -0.6803   -0.6803   -0.6803   -0.6803        
  -14.1803  -14.1803  -14.1803  -14.1803         
.
.
.
.
Xc(:,:,64) =

   -7.5112   -7.5112   -7.5112   -7.5112         
   -4.8926   -4.8926   -4.8926   -4.8926         
   -0.0081   -0.0081   -0.0081   -0.0081         
  -13.7577  -13.7577  -13.7577  -13.7577        

我怎样才能将所有这 64 块的第一列绘制成彼此平行的热图?

在 3D 中沿第二维度绘制切片

您可以使用 slice function. Note that this function generates surface objects (like surf does), in which the row index corresponds to the y axis and the column index to the x axis. So the first two coordinates in Xc have to be swapped with permute:

[ii, jj, kk] = ndgrid(-2:.5:2, -2:.8:2, -2:.4:2);
Xc = jj.*exp(-ii.^2-jj.^2-kk.^2); % example adapted from `slice` documentation
slice(permute(Xc, [2 1 3]), [], 1:size(Xc,2), [])
xlabel row, ylabel column, zlabel page
view(67, 31)
colorbar

在 2D 中沿第二维度绘制单个切片

二维索引Xc就可以了,用permute挤成一个矩阵,用imagesc:

column_index = 4;
imagesc(permute(Xc(:, column_index, :), [1 3 2]))