what is the function of guidata

1 view (last 30 days)
Feng
Feng on 8 Oct 2012
I tried to refer to the status of a button in GUI in an outside function. So I used the guidata (as well as findobj) to get the handle of the button. The unexpected consequence is that it also refresh a DAQ board on the PCI bus. This will turn off my other equipments connected to DAQ.
Does anyone know how I can avoid this problem, or to use other function instead?
Thanks,
Feng

Answers (1)

Julien
Julien on 8 Oct 2012
Edited: Julien on 8 Oct 2012
Hi,
guidata is a function to store and retrieve datas inside GUI's. It's a method to share datas between gui's component. But personnaly I don't use this function. If I use GUIDE, I prefer storing datas inside handles structure, which is always shared between components. if you want to separate handles from datas (for example to save or load datas from a mat file), then you can imagine to insert a data structure inside the handle structure (kind of handles.dat.mydata)
If you use findobj, you have to care about what property you are searching. Maybe other components you don't want to modify share the same properties.
to be sure, display inside command windows what findobj returns
disp(findobj('Property','propertyvalue))
  2 Comments
Image Analyst
Image Analyst on 8 Oct 2012
Just to clarify, you might still need guidata() if you use GUIDE. The handles structure is automatically shared between components (their callbacks) but if you call a function that you custom wrote, and that takes handles as an input, and if that function makes changes to handles (like you changed or added a member), then you will either have to call guidata, or else pass out handles as an output argument so that the calling function can call guidata. This does happen on occasion -- that you want to add things to the handles structure in your own custom function.
Julien
Julien on 8 Oct 2012
yes you're right ;) I forgot to mention it (I don't do that in guide generally, I prefer doing it programmatically)

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!