I have a problem in a Matlab GUI code. Let say for instance that I want to display in the console the value of a slider cursor in the GUI. But the fact is that I want to display it in real time, eg at each position of the cursor even if the click is still on, while moving it.
For this, I read on internet that the 'addlistener' function could help me. I put it in the slider_CreateFcn function like this :
function slider1_CreateFcn(hObject, eventdata, handles)
h=addlistener(hObject,'Value','PostSet',@(~,~)slider1_Callback)
Then, I added a simple disp function in the callback function, like this :
function slider1_Callback(hObject, eventdata, handles)
get(hObject,'value')
Running this code raise this error :
Warning: Error occurred while executing callback:
Error using get
Cannot find 'get' method for matlab.graphics.internal.GraphicsMetaProperty class.
Error in untitled>slider1_Callback (line xx)
get(hObject,'value')
If I remove the addlistener
function, obviously the update is no more in real time, but I don't get the error message. So I think that the problem is directly coming from the addlistener
function.
What is happening and how can I fix it?