Share script variable with GUI variable

Hi MATLAB Community, I'm creating a program that would send a variable from a script workspace to a Matlab GUI workspace. Ideally, I have a script which establishes a variable 'b' which I can access in the command window but not in the Matlab GUI. I understand that the script workspace is different from the GUI workspace.
Is it possible to share 'b' as a 'global variable' so I can rerieve data 'b' in the matlab GUI.
MATLAB SCRIPT
b = 10
GUI SCRIPT PUSH BUTTON
% --- Executes on button press in pairButton.
function pairButton_Callback(hObject, eventdata, handles)
% hObject handle to pairButton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
passed_variable = b;
Thank you very much in advance!

Respuestas (1)

Stephen23
Stephen23 el 28 de Feb. de 2018

0 votos

First you should pass that variable as an input argument to the GUI function. Then you can use any of the methods described on this page:
The wiki also explains this:
And some of the many threads on this forum that answer your question:
Personally I would recommend that you avoid using GUIDE, and write your own GUI programmatically. Then could use nested functions, which are simple, intuitive, and easy to debug.

Categorías

Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 27 de Feb. de 2018

Respondida:

el 28 de Feb. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by