ga output function problems

1 次查看(过去 30 天)
I use Matlab's built in ga algorithm to optimize a video input from a camera. I use ga's output function feature to adjust the camera's exposure time after each iteration. For that I need to change variables in the base workspace from within the function, which I do using assignin and evalin.
I have 2 problems: first, these external assignments are only performed after the ga is complete, and not immediately after each iteration, which is problematic for my needs; and second, it seems as though the command
double(getsnapshot(vid1))
where vid1 is my videoinput object, doesn't work from within the output function, but only when evaluated in the base workspace. And that's a problem because I need the snapshot for the ga's output function. Funny thing is that when I run the ga from optimtool's GUI interface it actually does work. And I double-checked to see there isn't anything wrong with the definition of my parameter object etc...
Also, earlier I executed the program from a 2016a version and if I recall correctly it worked fine, or at least the immediate external assignment problem. I'm usually using ver. 2015b. Could that be related?
Thanks.
Edit: the error I get for
im=double(getsnapshot(vid1));
is
Undefined function 'getsnapshot' for input arguments of type 'cell'.
but
class(vid1)
within the function returns 'videoinput'.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 COM Component Integration 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by