Filter löschen
Filter löschen

How to share data between two GUI ?

1 Ansicht (letzte 30 Tage)
Dipesh  Mudatkar
Dipesh Mudatkar am 1 Jul. 2018
Kommentiert: Dipesh Mudatkar am 1 Jul. 2018
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 Kommentare
Jan
Jan am 1 Jul. 2018
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 am 1 Jul. 2018
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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Jan
Jan am 1 Jul. 2018
Bearbeitet: Jan am 1 Jul. 2018
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 Kommentar
Dipesh  Mudatkar
Dipesh Mudatkar am 1 Jul. 2018
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by