Hello, I have a GUI and want to get the Data from the push button callback into the workspace to use it for further steps in my programm. Best regards Nico Subic

Antworten (1)

Jan
Jan am 9 Aug. 2017
Bearbeitet: Jan am 9 Aug. 2017

0 Stimmen

It is a bad idea in general to create data in the base workspace. Such a remote controlled creating of variables is hard to debug and suffers from the same problems as global variables (a short search in the net or the forum will reveal them).
But it works. If you post the relevant part of the code, posting an answer would require less creativity, but I try it:
function ButtonCallback(jObject, EventData, handles)
handles = guidata(hObject);
Data = handles.myData;
assignin('Base', 'DataFromGui', Data); % Working, but not smart
end
Again: I never create variables in the base workspace to avoid any possibility to overwrite other values. I keep the values inside the GUI and start the function from there by a callback. Or I add a function to the GUI, which let it reply the data, such that they can be requested from another function. Think twice if writing to the base workspace is really useful in a long term of view.

Kategorien

Mehr zu App Building finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 9 Aug. 2017

Bearbeitet:

Jan
am 9 Aug. 2017

Community Treasure Hunt

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

Start Hunting!

Translated by