如何单独绘制 X*Y*Z (3D) 矩阵 matlab?

How to separately subplot a X*Y*Z (3D) matrix matlab?

我想创建 4 个子图,每个子图包含 16 个数字。每个图形都是矩阵 GW 的一个维度。 IE。 GW(:,:,1) 是第一张图片。 这是我在第一个子图中的前 16 个图像的 for 循环。我应该如何修改 for 循环以获得 3 个以上的子图? 第一个子图应包含前 16 张图像,第二个子图应包含后 16 张图像,依此类推。通过以下循环,我获得了所有四个子图的前 16 张图像。

for i=1:4
        figure(i);
        hold on;

        for jj = 1:16
              subplot (4,4,j)
              imshow (GW(:,:,j));
        end
end

你只需要修改你访问GW 3rd维度的方式。试试这个:

num_figures = 4;  % because I dont like magic numbers in the code
subplots_per_figure = 16;  % same here
for i=1:num_figures
        figure(i);
        hold on;

        for j = 1:subplots_per_figure
              subplot (4,4,j)
              imshow (GW(:,:,j+(i-1)*subplots_per_figure));
        end
end