Addlistener error: Undefined function for input arguments of type 'matlab.ui.Figure'.

I am using addlistener in my openingFcn like this
handles.viewCAM_handles.listener = addlistener(viewCAM_handles.slider_master,'Value', 'PostSet',@(eventdata,viewCAM_handles)slider_master_continuousCallback(hObject,eventdata,handles));
But i get the error: Undefined function 'slider_master_continuousCallback' for input arguments of type 'matlab.ui.Figure'. Why can't I use a figure as input argument for my callback? What should I use instead, I tried with hObject but it gave me the same error.

 採用された回答

Walter Roberson
Walter Roberson 2016 年 6 月 29 日
I do not know why you are getting that error, but you need to change your code:
handles.viewCAM_handles.listener = addlistener(viewCAM_handles.slider_master,'Value', 'PostSet', @(hObject, eventdata) slider_master_continuousCallback(hObject, eventdata, handles));
and keep in mind that the handles that will be passed will not include handles.viewCAM_handles.listener because it will be passed by value with the value as of the line before (because the right hand side is evaluated before the left)

5 件のコメント

Joakim Magnusson
Joakim Magnusson 2016 年 6 月 29 日
Now the error change to: ...for input arguments of type 'matlab.graphics.internal.GraphicsMetaProperty'.
Walter Roberson
Walter Roberson 2016 年 6 月 29 日
It sounds as if you have not defined any routine named slider_master_continuousCallback in a slider_master_continuousCallback.m; or in the same file; or as a nested function.
Joakim Magnusson
Joakim Magnusson 2016 年 6 月 29 日
編集済み: Joakim Magnusson 2016 年 6 月 29 日
Oh sorry, forgot to write that the slider is in another .m - file. I have several gui's but the main gui and it's m-file is where i use addlistener. The reason is because in the continuouscallback in the other m-file is using handles from the main m-file. if i don't put addlistener in the main file the continuouscallback function doesn't have the right handles from the main m file.
It's hard to explain but maybe you understand?
Maybe i just did it wrong with the handles when i didn't have addlistener in my main file?
Joakim Magnusson
Joakim Magnusson 2016 年 6 月 29 日
The problem was that i tried to call a function inside a m-file from another m-file...
Walter Roberson
Walter Roberson 2016 年 6 月 29 日
Yep, that will cause problems every time.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by