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