How to: Sharing variable from one function to another function in GUI
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello All, I am working on a GUI where I want to take input from user and use the variable in another function which is in a separate .m file.
I tried defining the variable as global but still the file where I want to call the value returns "undefined" error.
selection = get(hObject, 'Value');
switch selection
case 1
M2.h=msgbox('Please select the value');
case 2
M2.x2=1;
case 3
M2.x2=2;
case 4
M2.x2=3;
prompt = {'Value1','Value2'};
dlg_title = 'Properties';
num_lines = 1;
defaultans = {'',''};
answer = inputdlg(prompt,dlg_title,num_lines,defaultans);
M2.Value1=str2num(answer{1});
M2.Value2=str2num(answer{2});
end
set(handles.value_type, 'UserData', M2);
Now I want to call the Value1, Value2 in a separate .m file which runs in the script where above code is. Meaning the above code is a part of GUI which calls the functions from the another m file where I want the above input to be used.
0 commentaires
Réponses (2)
Voir également
Catégories
En savoir plus sur Whos dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!