how to combine 2 figure into 1 figure? use copyobj and findobj function
Show older comments

fig1 = open('1.fig');
axesObjs = get(fig1, 'Children');
dataObjs = get(axesObjs, 'Children');
fig2 = open('2.fig');
axesObjs = get(fig2, 'Children');
dataObjs = get(axesObjs, 'Children');
copyobj(findobj(fig2, 'Type', 'image'), gca(fig1));
Answers (1)
KSSV
on 2 Feb 2017
0 votes
You have to get the x and y data from the figures. See this link to extract the data from .fig file: https://in.mathworks.com/matlabcentral/answers/100687-how-do-i-extract-data-from-matlab-figures
Define the new position for the figures where you want to place them and plot in single figure.
6 Comments
KSSV
on 2 Feb 2017
First, Without getting solution you should not accept the answer.
Attach your .fig's here; let me give a try.
KSSV
on 2 Feb 2017
Hello what you have are jpg's...in your question you have mentioned extension .fig....it makes a difference in solution.
Mei Synn Tan
on 3 Feb 2017
Good Morning Dr. KSSV, here it is. Thanks
KSSV
on 3 Feb 2017
KSSV
on 3 Feb 2017
Mei Synn Tan
on 3 Feb 2017
It is useful and work for me, but now I need to select interest point based on X and Y axes. So I need to find a way to combine 2 figure into new figure. Hope Dr. KSSV can help me, Thanks.
I = imread('13100.jpg');
im = imshow(I);
e = imellipse(gca, [ 148.0061 38.96 30 30]);% now pick ROI
setColor(e, 'red');
position = wait(e);
BW = createMask(e,im);% get BW mask for that ROI
BW(:,:,2) = BW;
BW(:,:,3) = BW(:,:,1);
ROI = I;
ROI(BW == 0) = 255;
e1 = imellipse(gca, [ 176.4832 78.71 30 30]);% now pick ROI
position = wait(e1);
setColor(e1, 'red');
position = wait(e1);
BW1 = createMask(e1,im);% get BW mask for that ROI
BW1(:,:,2) = BW1;
BW1(:,:,3) = BW1(:,:,1);
ROI1 = I;
ROI1(BW1 == 0) = 255;
figure,imshow(ROI,'Border','tight');
figure,imshow(ROI1,'Border','tight');
Categories
Find more on Image Arithmetic 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!