ravi.panch
ravi.panch

Reputation: 637

Different subplots on different figures - MATLAB

Any suggestions are appreciated. I want to show 2 different figures with different subplots.

Ex:

% Figure 1, subplot 1
subplot(1,2,1); 
imshow(img1);
subplot(1,2,2); 
imshow(img2);

% Figure 2, subplot 2
subplot(1,2,1); 
imshow(img3);
subplot(1,2,2); 
imshow(img4);

% Also another Figure 3, with some image
figure, imshow(img5);

Thank you.

Upvotes: 1

Views: 13996

Answers (1)

gary
gary

Reputation: 4255

The syntax is figure(h), where h is the figure's handle which allows you to specify properties of the figure, including figure number (as explained in Matlab reference).

If you only care about the figure number, you can just set h to the figure number (integer).

% Figure 1, subplot 1
figure(1);                 % this puts the upcoming subplots onto figure 1
subplot(1,2,1); 
imshow(img1);
subplot(1,2,2); 
imshow(img2);

% Figure 2, subplot 2
figure(2);                 % this puts the upcoming subplots onto figure 2
subplot(1,2,1); 
imshow(img3);
subplot(1,2,2); 
imshow(img4);

% Also another Figure 3, with some image
figure(3);                 % this puts the upcoming imshow onto figure 3
imshow(img5);

Upvotes: 3

Related Questions