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!

Antworten (1)

Stephen23
Stephen23 am 28 Feb. 2018

0 Stimmen

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.

Kategorien

Mehr zu Startup and Shutdown finden Sie in Hilfe-Center und File Exchange

Produkte

Gefragt:

am 27 Feb. 2018

Beantwortet:

am 28 Feb. 2018

Community Treasure Hunt

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

Start Hunting!

Translated by