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

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!

0 Comments

Nabeshin

Products

2 Answers

Answer by 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 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 on 16 Nov 2012

add to your code

data=[calibro massa]
set(handles.proiettile_personalizzato,'Userdata',data)
Azzi Abdelmalek
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. http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F

0 Comments

Image Analyst

Contact us