필터 지우기
필터 지우기

How to share data between two GUI ?

조회 수: 1 (최근 30일)
Dipesh  Mudatkar
Dipesh Mudatkar 2018년 7월 1일
댓글: Dipesh Mudatkar 2018년 7월 1일
Problem:
1. Two GUI are created with name First.fig / First.m and Second.fig / Second.m.
2. Both GUI have two radio button namely first and second.
3. With one condition : only once GUI can be open at a time.
4. Expected output should be if second radio button is selected in First GUI then it should get reflected in second radio button of Second GUI.
  댓글 수: 2
Jan
Jan 2018년 7월 1일
This cannot work due to restriction 3. : If you can open one GUI only, you cannot share data between two GUIs.
So please explain the problem more clearly.
Dipesh  Mudatkar
Dipesh Mudatkar 2018년 7월 1일
Hi Jan,
Thank you for your reply.
If I remove 3rd condition then, is it possible to link the both GUI's radio buttons in such a way that user can select the particular radio button in First GUI and same will get reflected in the Second GUI. (Basically, I want to sync radio button of both GUI with each other).
so if user select first radio button in First GUI it shows the same in second GUI without selecting in second GUI.
your assistant will be greatly appreciated.

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2018년 7월 1일
편집: Jan 2018년 7월 1일
function CreateGUI1
FigH = figure('Tag', 'GUI1', 'Name', 'GUI 1');
handles.Radio(1) = uicontrol('Style', 'Radiobutton', 'String', 'Radio 1', ...
'Position', [10, 10, 100, 30]);
handles.Radio(2) = uicontrol('Style', 'Radiobutton', 'String', 'Radio 2', ...
'Position', [10, 40, 100, 30]);
guidata(FigH, handles);
end
And the 2nd GUI:
function CreateGUI2
FigH = figure('Tag', 'GUI2', 'Name', 'GUI 2');
handles.Radio(1) = uicontrol('Style', 'Radiobutton', 'String', 'Radio 1', ...
'Position', [10, 10, 100, 30], ...
'Callback', {@radio, 1});
handles.Radio(2) = uicontrol('Style', 'Radiobutton', 'String', 'Radio 2', ...
'Position', [10, 40, 100, 30], ...
'Callback', {@radio, 2});
guidata(FigH, handles);
end
function radio(RadioH, EventData, Index)
% Get handle and handles struct of GUI1:
GUI1 = findobj(allchild(groot), 'flat', 'Tag', 'GUI1');
handlesGUI1 = guidata(GUI1H);
handlesGUI2 = guidata(RadioH);
if Index == 1
handlesGUI1.Radio(1).Value = 1; % Copy state to other GUI
handlesGUI1.Radio(2).Value = 0; % Copy state to other GUI
handlesGUI2.Radio(2).Value = 0; % Disable the other radio button
else
handlesGUI1.Radio(2).Value = 1;
handlesGUI1.Radio(1).Value = 0;
handlesGUI2.Radio(1).Value = 0;
end
end
  댓글 수: 1
Dipesh  Mudatkar
Dipesh Mudatkar 2018년 7월 1일
Hi Jan,
Can you please once check the attached files present in the original question? and what is the problem in that if you explain it, it will be helpful.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by