Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
pass info from secondary GUI to the main GUI

Subject: pass info from secondary GUI to the main GUI

From: Wendy

Date: 7 Dec, 2010 02:58:05

Message: 1 of 1

Hi All,

I am creating a GUI with multiple windows.

On the main GUI, I press a button called 'Main Button', and it brings a secondary GUI called 'Main Button'

function pushbutton_UpregGene_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_UpregGene (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

MainButton; % Name of the 2nd GUI
handles.Graph.MainButton= getappdata(0,'UpregGene'); % pass the 'UpregGene' into handles.Graph structure of the Main GUI
guidata(hObject, handles);

In the secondary GUI called 'MainButton', I load data from an excel file after specifying the file names. The data are save in a structure called 'UpregGene'. I want to pass the 'UpregGene' to the handle.Graph structure in the main GUI by pressing a 'ok' button in the secondary GUI (called 'MainButton'). The code is following

function pushbutton_ok_Callback(hObject, eventdata, handles)
    myfile = get(handles.text_UpregGeneDirectory,'String');
    load(myfile); % The structure name is 'UpregGene'

But the main GUI runs 'handles.Graph.MainButton= getappdata(0,'UpregGene')' before I specify anything in the secondary GUI. Does anyone know how to get around this? Shall I use CreateFcn?

Thanks a lot,

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us