hi. i have two guis main and sub . i have stored inputs from all the edit boxes in sub in a variable, var. i need to tranfer var to main gui.and use it for further logic.kindly help.

function data_Callback(hObject, eventdata, handles)
% hObject handle to data (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
points.T=str2double(get(handles.edit1,'userdata'));
points.ES=str2double(get(handles.edit2,'userdata'));
points.ISlower=str2double(get(handles.edit3,'userdata'));
points.ISupper=str2double(get(handles.edit4,'userdata'));
points.G=str2double(get(handles.edit5,'userdata'));
set(handles.data,'userdata',points);
close(details);
this is the call back of a pushbutton in sub.
i need to transfer the variable 'points' to main function pushbutton callback.

 Accepted Answer

Hi Alankrita, you can use assignin command to save the variables in base workspace and use evalin command to access them from the main gui

5 Comments

hi. thanks for the reply. can you explain me in detail hw it works? i have 2 guis main and sub. from main i am opening sub and giving inputs through edit boxes ans storing them in a variable 'points'. i need to pass this variable to main gui and use it for my further logic. can you give me the commands for this?
In the first gui, where you are reading the values use the below command
>>assignin('base', 'var', val)
% var is the variable name
% val is the value of the variable
In the sub gui, where you want to read the variables
>>evalin('base','var')
hi. i tried this but its not able to assign the values in main gui. kindly have a look at the snapshots . .
Hi, Please check the attached example.
Let me know if it is working :)

Sign in to comment.

Categories

Community Treasure Hunt

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

Start Hunting!