subplot two different images in two different for loop
Show older comments
I need to display two images suppose as in my case it is patch 1 (P1) and patch2 (P1*) as simultaneous subplots like using for loop
again after incrementing the for loop the upcoming two images should come as the next subplots
But iam getting all P1 to P20 first then P*1 is coming as P*21 which is not what i ought to do as shown below:

I need first P1 and P*1
Here is the code:
% Plotting the patches
figure;
k=1;
for i = 1 : 40 : rowsI-40
for j = 1 : 40 : columnsI-40
im_subL=I(i:i+39,j:j+39);
im_subR=imr(i:i+39,j:j+39);
subplot(round(rowsI/40),round(columnsI/40),k),imshow(im_subL);
title(['P',num2str(k)])
subplot(round(rowsR/40),round(columnsR/40),k+1),imshow(im_subR);
title(['P*',num2str(k+1)])
k=k+1;
end
end
I need to correct it could anybody please suggest me what to do?
Accepted Answer
More Answers (1)
KALYAN ACHARJYA
on 29 Jun 2019
P*1 is coming as P*21 which is not what i ought to do?
As the title is displayed based on k value, as it reflects the number of iteration, as you have defined k=1
and within the loop
k=k+1;
When the code has to be displayed P*1 again, you may look for another variable, say l, as similar as k, for lower parts plots. (* displayed, I am supposing it exucated the lower title)
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!