newbie GUIDE passing data through popup windows

2 views (last 30 days)
Hello everybody I built a gui using GUIDE but I have a problem I cannot resolve. In my gui when I click on a button I make appear a new window with two empty fields. Using the command inputdlg I am able two acquire two diferent numeric data. Now the problem is that I want to make that data available for the main function of my gui. I explain better the problem. I want to click on a button, define a certain number of numeric parameters in a new window, close that window and using the parameters I acquired in another function. Someone could help me or give me any advices? Thank you in advance to everyone!

Answers (2)

Azzi Abdelmalek
Azzi Abdelmalek on 16 Nov 2012
you can store those data in Userdata of any of your objects
set(handles.yourobject,'Userdata',data)
use
data=get(handles.yourobject,'Userdata')
  2 Comments
Nabeshin
Nabeshin on 16 Nov 2012
Thanks but it is still not clear to me. I have this function that is the one in which I define my two parameters. The two parameters are calibro and massa. Now I cannot understand how to apply your advice. (excuse for me stupid question!)
function proiettile_personalizzato_Callback(hObject, eventdata, handles)
% hObject handle to proiettile_personalizzato (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
prompt = { ' Calibro Proiettile '...
' Massa Proiettile '};
name = 'Dati Proiettile Personalizzato';
numlines = 1;
defaultanswer = {'0','0'};
answer = inputdlg(prompt,name,numlines,defaultanswer);
if isempty(answer) ~= 1
calibro = str2double(answer{1});
massa = str2double(answer{2});
end if true
% code
end
Azzi Abdelmalek
Azzi Abdelmalek on 16 Nov 2012
add to your code
data=[calibro massa]
set(handles.proiettile_personalizzato,'Userdata',data)

Sign in to comment.


Image Analyst
Image Analyst on 17 Nov 2012
Check the FAQ for several methods of sharing variables between different custom functions, call back functions and different GUIs. http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!