Reputation: 39
I'd like to create 4 subplots each containing 16 figures. Each figure is one dimension of the matrix GW. I.e. GW(:,:,1) is the first image. Here is my for loop for the first 16 images in first subplot. How should I modify the for loop to get 3 more subplots? The first subplot should contain first 16 images, second subplot should contain second 16 images and so on. With the following loop I'm getting first 16 images for all the four subplots.
for i=1:4
figure(i);
hold on;
for jj = 1:16
subplot (4,4,j)
imshow (GW(:,:,j));
end
end
Upvotes: 0
Views: 135
Reputation: 473
You just need to modify how you access the 3rd dimension of GW. 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
Upvotes: 0