MATLAB: How to plot two subplots side by side in one figure

figurefor loopsubplot

Hello,
I'd like to plot two subplots side by side in one figure. I currently have two subplots in a for loop each, and from what I've read online, MATLAB doesn't allow to plot a subplot within a subplot. Is there another way of plotting these subplots alongside each other?
suplotTitle = {'0.4mA', '0.6mA', '0.8mA', '1.2', '1.6mA'};
f1=figure
for ii=1:5
subplot(5,1,ii);
b1 = bar(conRR(2:end,1), conRR(2:end, ii+1));
b1.FaceColor = '#D95319';
b1.EdgeColor = 'none';
xticks(1:1:16);
ylim([0 80]);
title(suplotTitle{ii})
end
f2=figure
for ii=1:5
subplot(5,1,ii);
b2 = bar(b9RR(2:end,1), b9RR(2:end, ii+1));
b2.FaceColor = '#0072BD';
b2.EdgeColor = 'none';
xticks(1:1:16);
ylim([0 80]);
title(suplotTitle{ii})
end
I have tried converting the subplots into images using the following code:
F1 = getframe(f1);
[X1, Map1] = frame2im(F1);
F2 = getframe(f2);
[X2, Map2] = frame2im(F2);
and then plotting a subplot with the images:
figure;
subplot(1,2,1), imshow(X1,Map1)
subplot(1,2,2), imshow(X2,Map2)
However, the quality of the figure (images) are not that great.
Would appreciate any feedback to plot the subplots another way or to perhaps improve the quality of the images.
Thanks.

Best Answer

Try this:
conRR = [(0:10).' rand(11,5)*80]; % Create Matrix

b9RR = [(0:10).' rand(11,5)*80]; % Create Matrix
f1=figure
for ii=1:5
subplot(5,1,ii);
b1 = bar(conRR(2:end,1), conRR(2:end, ii+1));
b1.FaceColor = '#D95319';
b1.EdgeColor = 'none';
xticks(1:1:16);
ylim([0 80]);
title(suplotTitle{ii})
end
f2=figure
for ii=1:5
subplot(5,1,ii);
b2 = bar(b9RR(2:end,1), b9RR(2:end, ii+1));
b2.FaceColor = '#0072BD';
b2.EdgeColor = 'none';
xticks(1:1:16);
ylim([0 80]);
title(suplotTitle{ii})
end
That appears to do what you want it to do.