简体   繁体   中英

GUIDE in MATLAB

I am trying to build a program in MATLAB and I am using edit boxes but I want the value that the user will enter to be used later on from another function. So should I use the global variables or is there another way?

I tried to define the global variables outside the function but is not working. I tried to define it inside the function and then call it from another function but it says that it is undefined. Is there a way that I can do that?

I am just using

function edit1_Callback(hObject, eventdata, handles)
str2double (get (hObject,'String'));

Thanks!! :)

If you want to store data within a Matlab-GUI, you can use the handles-structure like this:

handles.myVar=123;
%after this dont forget to save it (yes, this is a bit annoying):
guidata(hObject, handles);

later on, within another callback for example, you can find this data within the handles-struct:

handles.myVar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM