Pass extra parameter to UpdatePreviewWindowFcn (anonymous function required?)

I have written some code to get a preview stream from a camera and display it in a figure after modifying it. In the figure I have the following statement:
setappdata(previewImage,'UpdatePreviewWindowFcn',@GUI_editPreview);
where GUI_editPreview is the function that changes the data before display. At the moment I do not pass any parameter to the function but I would like to add one. I have tried to use:
setappdata(previewImage,'UpdatePreviewWindowFcn',{@GUI_editPreview, myParameter});
But Matlab produces an error "UpdatePreviewWindowFcn must be configured to a function_handle." I suspect I have to use anonymous functions but I could not figure out a way to do it correctly. What would be the correct syntax, in this case?

 採用された回答

PaoloB
PaoloB 2015 年 5 月 18 日
I found a workaround:
instead of passing the parameter in the function, I save it as an appdata of the previewImage. I can then retrieve it when needed. So my code becomes:
setappdata(previewImage,'UpdatePreviewWindowFcn',@GUI_editPreview);
setappdata(previewImage,'HandleToMainFig',mainFig);
and in the GUI_editPreview I use
mainFig = getappdata(himage,'HandleToMainFig');

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeProgramming Utilities についてさらに検索

質問済み:

2015 年 5 月 18 日

回答済み:

2015 年 5 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by