what is the function of guidata

2 次查看(过去 30 天)
Feng
Feng 2012-10-8
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

回答(1 个)

Julien
Julien 2012-10-8
编辑:Julien 2012-10-8
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 个评论
Image Analyst
Image Analyst 2012-10-8
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 2012-10-8
yes you're right ;) I forgot to mention it (I don't do that in guide generally, I prefer doing it programmatically)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by