[英]How to separately subplot a X*Y*Z (3D) matrix matlab?
I'd like to create 4 subplots each containing 16 figures. 我想创建4个子图,每个子图包含16个图形。 Each figure is one dimension of the matrix GW.
每个图是矩阵GW的一维。 Ie GW(:,:,1) is the first image.
即GW(:,:,1)是第一张图片。 Here is my for loop for the first 16 images in first subplot.
这是第一个子图中前16个图像的for循环。 How should I modify the for loop to get 3 more subplots?
我应该如何修改for循环以获得3个以上的子图? The first subplot should contain first 16 images, second subplot should contain second 16 images and so on.
第一个子图应包含前16个图像,第二个子图应包含后16个图像,依此类推。 With the following loop I'm getting first 16 images for all the four subplots.
通过以下循环,我将获得所有四个子图的前16张图像。
for i=1:4
figure(i);
hold on;
for jj = 1:16
subplot (4,4,j)
imshow (GW(:,:,j));
end
end
You just need to modify how you access the 3rd dimension of GW. 您只需要修改访问GW的第3维的方式即可。 Try this:
尝试这个:
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.