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

Réponses (1)

Jan
Jan le 9 Août 2017
Modifié(e) : Jan le 9 Août 2017

0 votes

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.

Catégories

En savoir plus sur App Building dans Centre d'aide et File Exchange

Tags

Question posée :

le 9 Août 2017

Modifié(e) :

Jan
le 9 Août 2017

Community Treasure Hunt

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

Start Hunting!

Translated by