- Locate the handle for the panel in A (call it hp_A)
- Locate the handle for the panel in B (call it hp_B)
- To copy the Children (uicontrols) from hp_B to hp_A, you just have to set their Parent from hp_B to hp_A.
How do I copy a panel from one figure to another?
조회 수: 5 (최근 30일)
이전 댓글 표시
I have a figure A.fig and it has a panel A.pan, which is on A.fig. I have a pushbutton on A.fig that creates a new figure, B.fig, with its own panel, B.pan.
I have tons of uicontrols on both A.pan and B.pan. I have a pushbutton on B.fig that, when you hit it, should close B.fig and copy its contents (everything on B.pan) over to A.pan.
I've checked out findobj/findall, setappdata/getappdata, guidata, etc. but have not found a solution. The problem comes from A and B being completely separated. Also, I'm having a hard time figuring out what A and B are. I mean, they look like structures, but then A.fig.Parent will return a graphics root object, yet somehow I can have A.btn1, A.btn2, A.sidebar, A.text1, A.text2, A.radio1, A.radio2, and even more, which are definitely not root properties and makes me think I have a struct. I'm guessing A.fig.Parent is not the structure it belongs in, but then how do I access that structure?
Right now, I have the pushbutton on B so that it closes B.fig and makes A.pan visible, but A.pan is not a clone of B.pan, as I would like it to be.
Any help on how what A and B are, how to access them (maybe with findobj or something), and how to move the panel contents of B.pan to A.pan?
댓글 수: 0
채택된 답변
Dimitris Iliou
2017년 6월 16일
If I understand correctly, you want to copy the contents of the panel in figure B to the panel in figure A, and after that close figure B.
In order to access A while in B you could use findobj. The easiest way to do that is by using Tags.
For example, if you create a figure using the following code:
A = figure('Tag','Main');
You should be able to find that handle using findobj in the following way:
h = findobj('-regexp','Tag','Main');
In order to achieve your workflow, you need to perform the following steps:
For example, the code for that would look something like this:
hp_B.Children(1).Parent = hp_A;
Also, you can find more information on Graphics Objects in the following documentation links:
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!