Data handling in GUI

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

Risposte (1)

Jan
Jan il 9 Ago 2017
Modificato: Jan il 9 Ago 2017
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.

Categorie

Scopri di più su App Building in Centro assistenza e File Exchange

Tag

Richiesto:

il 9 Ago 2017

Modificato:

Jan
il 9 Ago 2017

Community Treasure Hunt

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

Start Hunting!

Translated by