0

Inside a GUI that I have made using GUIDE in Matlab. I run into a problem where upon using the Load() function to load a .MAT file all my handles change values. This means that if I had a button that I wanted to use on my GUI. My program will believe its handle is for example

 handles.button1 =190.082

when in reality the only way I can access that button any more is through a different handle that is unknown. So if its unknown lets see what its new handle must be.

findobj('Tag','button1') = 227.0093

As you can see these numbers are completely different. Why the handles values get changed is beyond me. Since the handles change I can no longer use the set() function as I have written in previous sections of code. For example I have to change

set(handles.button1, 'Enable', 'off');

to 

set(findobj('Tag','button1'),'Enable','off');

Does anyone have an explanation as to why this problem occurs when using Load()? Is there a feasible solution instead of having to find the handle for an object every time you want to use it?

Zaheer Ahmed
  • 28,160
  • 11
  • 74
  • 110
David Hassan
  • 155
  • 1
  • 10
  • Why are you loading the handle values? It is normal that they would change. – HebeleHododo Apr 18 '13 at 12:23
  • I apologize if that's how you interpreted my question. I am not loading the handle values using Load(). I am using Load() to load in some external variables from another program. Upon using the Load() function. My program changes all its handles. – David Hassan Apr 18 '13 at 12:28
  • 1
    It is probably because there is a handles structure in your .mat file. Do not load it, or remove it from the .mat file. – HebeleHododo Apr 18 '13 at 12:38
  • Yes thank you HebeleHododo. I was unaware of the .mat also having the handles. Well I think I have felt silly enough today. – David Hassan Apr 18 '13 at 12:46

1 Answers1

0

The .MAT file conveniently also had a handles variable in it which overwrote my current handles.

David Hassan
  • 155
  • 1
  • 10