Hi, I have a problem in matlab. I want to create a number containing 10 subplots. in orientation 2X5. But the problem is that I want to reduce the area of ββdead space between them. I also need to keep the title, xlabel for the first line of images and xlabel (only) for the second line of images. No yards required.
So far I have done this code (for the first line): as soon as I draw the first line, the second line should be a piece of cake.
close all figure,set(gca,'Color','none') subplot(2,5,1);subplot('Position',[0.02 0.51 0.18 0.45]);get(gca,'position');set(gca, 'XTick', []);set(gca, 'YTick', []); imshow(I);hold on; axis off; contour((BW(:,:,1)), [0 0], 'r','LineWidth',2); hold off;title('1st curve','FontSize',12);xlabel('(a)','FontSize',12) subplot(2,5,2);subplot('Position',[0.215 0.51 0.18 0.45]);get(gca,'position');set(gca, 'XTick', []);set(gca, 'YTick', []); imshow(I);hold on; axis off; contour((BW(:,:,2)), [0 0], 'r','LineWidth',2); hold off;title('2nd curve','FontSize',12);xlabel('(b)','FontSize',12) subplot(2,5,3);subplot('Position',[0.410 0.51 0.18 0.45]);get(gca,'position');set(gca, 'XTick', []);set(gca, 'YTick', []); imshow(I);hold on; axis off; contour((BW(:,:,3)), [0 0], 'r','LineWidth',2); hold off;title('3rd curve','FontSize',12);xlabel('(c)','FontSize',12) subplot(2,5,4);subplot('Position',[0.605 0.51 0.18 0.45]);get(gca,'position');set(gca, 'XTick', []);set(gca, 'YTick', []); imshow(I);hold on; axis off; contour((BW(:,:,4)), [0 0], 'r','LineWidth',2); hold off;title('4th curve','FontSize',12);xlabel('(d)','FontSize',12) subplot(2,5,5);subplot('Position',[0.8 0.51 0.18 0.45]);get(gca,'position');set(gca, 'XTick', []);set(gca, 'YTick', []); imshow(I);hold on; axis off; contour((BW(:,:,5)), [0 0], 'r','LineWidth',2); hold off;title('5th curve','FontSize',12);xlabel('(e)','FontSize',12)
This gives me this conclusion:

As you can see, the fourth image is missing. What is wrong with the code? I rechecked my code and calculations several times, too, but could not find the error.
I wonder when I run this code [with only the 4th subtitle]
subplot(2,5,4);subplot('Position',[0.605 0.51 0.18 0.45]);get(gca,'position');set(gca, 'XTick', []);set(gca, 'YTick', []); imshow(I);hold on; axis off; contour((BW(:,:,4)), [0 0], 'r','LineWidth',2); hold off;title('4th curve','FontSize',12);xlabel('(d)','FontSize',12)
I get this answer !! 
Please tell me where am I wrong? Note. I need xlabel and a title for the first line of images.
EDIT: I then went and did it. Now I get five images. However, the interval between images in all cases is uneven, in particular, the distance between the 1st and 2nd images differs from the others.
My code is:
close all figure,set(gca,'Color','none') subplot(2,5,1);subplot('Position',[0.02 0.51 0.18 0.45]);get(gca,'position');set(gca, 'XTick', []);set(gca, 'YTick', []); imshow(I);hold on; axis off; contour((BW(:,:,1)), [0 0], 'r','LineWidth',2); hold off;title('1st curve','FontSize',12);xlabel('(a)','FontSize',12) subplot(2,5,2);subplot('Position',[0.210 0.51 0.18 0.45]);get(gca,'position');set(gca, 'XTick', []);set(gca, 'YTick', []); imshow(I);hold on; axis off; contour((BW(:,:,2)), [0 0], 'r','LineWidth',2); hold off;title('2nd curve','FontSize',12);xlabel('(b)','FontSize',12) subplot(2,5,3);subplot('Position',[0.405 0.51 0.18 0.45]);get(gca,'position');set(gca, 'XTick', []);set(gca, 'YTick', []); imshow(I);hold on; axis off; contour((BW(:,:,3)), [0 0], 'r','LineWidth',2); hold off;title('3rd curve','FontSize',12);xlabel('(c)','FontSize',12) subplot(2,5,4);subplot('Position',[0.600 0.51 0.18 0.45]);get(gca,'position');set(gca, 'XTick', []);set(gca, 'YTick', []); imshow(I);hold on; axis off; contour((BW(:,:,4)), [0 0], 'r','LineWidth',2); hold off;title('4th curve','FontSize',12);xlabel('(d)','FontSize',12) subplot(2,5,5);subplot('Position',[0.795 0.51 0.18 0.45]);get(gca,'position');set(gca, 'XTick', []);set(gca, 'YTick', []); imshow(I);hold on; axis off; contour((BW(:,:,5)), [0 0], 'r','LineWidth',2); hold off;title('5th curve','FontSize',12);xlabel('(e)','FontSize',12)
Now I get this answer: 
How can i fix this? Help! Thanks in advance!
EDIT: It seems I solved this problem. Please show my answer below. However, I have a request. I wanted to make the code run in a loop and thus implement this code.
I = imread('coins.png'); I = imresize(I,[128 128]); for no = 1:5 subplot('Position',[0.025+0.19*(no-1) 0.51 0.19 0.48]); imshow(I); get(gca,'Position');set(gca, 'XTick', []);set(gca, 'YTick', []); title({'Image' num2str(no)}); subplot('Position',[0.025+0.19*(no-1) 0.03 0.19 0.48]); imshow(I); get(gca,'Position');set(gca, 'XTick', []);set(gca, 'YTick', []); title({'Image' num2str(no)}); end
The answer goes like this 
Can this code be vectorized ??