MATLAB Answers


newbie GUIDE passing data through popup windows

Asked by Nabeshin
on 16 Nov 2012

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!


Log in to comment.

2 Answers

Answer by Azzi Abdelmalek
on 16 Nov 2012

you can store those data in Userdata of any of your objects





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

add to your code

data=[calibro massa]

Log in to comment.

Answer by 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.


Log in to comment.

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today